CodeForces - 765B Code obfuscation 水题。
2017-08-22 20:31
141 查看
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
output
input
output
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.
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.
#include <bits/stdc++.h> using namespace std; const int N = 500 + 10; char a ; int vis ; int main(){ while(~scanf("%s", &a)){ memset(vis, 0, sizeof(vis)); int l = strlen(a); int flag = 1; for(int i = 0; i < l; i++){ int m = a[i]-'a'; for(int j = 0; j < m; j++){ if(!vis[j]){ flag = 0; } } vis[m] = 1; } printf(flag ? "YES\n" : "NO\n"); } }
相关文章推荐
- CodeForces 616A(水题)
- 平常水题 - CodeForces - 304A
- CodeForces--621A--Wet Shark and Odd and Even(数学水题)
- Codeforces 624B Making a String 【水题】
- [codeforces]A. The New Year: Meeting Friends 水题
- Codeforces 723A The New Year: Meeting Friends(题意有偏差的水题)
- codeforces 625B KMP水题
- Codeforces 466A Cheap Travel(水题)
- Maximum Value - CodeForces 484 B 水题
- Codeforces--400A--Inna and Choose Options(模拟水题)
- codeforces 733D (水题)
- codeforces 653A A. Bear and Three Balls(水题)
- codeforces水题100道 第三题 Codeforces Beta Round #47 A. Domino piling (math)
- Codeforces 638A Home Numbers 【水题】
- codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)
- Codeforces 659A Round House【水题,细节】
- codeforces_344B_Simple Molecules(水题)
- Codeforces 712A Memory and Crow 水题
- CodeForces 289A Polo the Penguin and Segments (水题)
- Codeforces--584A--Olesya and Rodion(水题)