Fellow me on GitHub

CodeForces765B

B. Code obfuscation

time limit per test:2 seconds
memory limit per test:512 megabytes
input:standard input
output:standard output

Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.

To obfuscate the code, Kostya first looks at the first variable name used in his program and replaces all its occurrences with a single symbol a, then he looks at the second variable name that has not been replaced yet, and replaces all its occurrences with b, and so on. Kostya is well-mannered, so he doesn't use any one-letter names before obfuscation. Moreover, there are at most 26 unique identifiers in his programs.

You are given a list of identifiers of some program with removed spaces and line breaks. Check if this program can be a result of Kostya's obfuscation.

Input

In the only line of input there is a string S of lowercase English letters (1 ≤ |S| ≤ 500) — the identifiers of a program with removed whitespace characters.

Output

If this program can be a result of Kostya's obfuscation, print "YES" (without quotes), otherwise print "NO".

Examples

input

abacaba

output

YES

input

jinotega

output

NO

Note

In the first sample case, one possible list of identifiers would be "number string number character number string number". Here how Kostya would obfuscate the program:

  • replace all occurences of number with a, the result would be "a string a character a string a",
  • replace all occurences of string with b, the result would be "a b a character a b a",
  • replace all occurences of character with c, the result would be "a b a c a b a",
  • all identifiers have been replaced, thus the obfuscation is finished.

 

 1 //2017-02-14
 2 #include <iostream>
 3 #include <cstdio>
 4 #include <cstring>
 5 
 6 using namespace std;
 7 
 8 int book[30];
 9 
10 int main()
11 {
12     string S;
13     char cur_max;
14     bool fg;
15     while(cin>>S)
16     {
17         fg = true;
18         memset(book, 0, sizeof(book));
19         for(int i = 0; i < S.length(); i++)
20               book[S[i]-'a']++;
21         for(int i = 1; i < 26; i++)
22               if(book[i]!=0 && book[i-1]==0)
23             {
24                 fg = false;
25                 break;
26             }
27         cur_max = S[0];
28         if(cur_max != 'a')fg = false;
29         for(int i = 1; i < S.length(); i++)
30         {
31             if(S[i]>cur_max && S[i]-cur_max==1)cur_max = S[i];
32             else if(S[i]>cur_max && S[i]-cur_max>1){
33                 fg = false;
34                 break;
35             }
36         }
37         if(fg)cout<<"YES"<<endl;
38         else cout<<"NO"<<endl;
39     }
40 
41     return 0;
42 }

 

posted @ 2017-02-14 21:53  Penn000  阅读(371)  评论(0编辑  收藏  举报