CF 397 B. Code obfuscation

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.

题意就是说:
Kostya这个人很喜欢打CF(巨巨啊),但是老是被人Hack(好不幸),他很生气,所以他想通过降低自己代码的可读性来防止被Hack(看不懂怎么Hack,厉害了)加密方式是看到的第一个类型的变量用‘a’替换,第二个用‘b'替换,以此类推。同时变量类型不超过26种,就是说26个字母就可以完成加密了。同时Kostya是一个绅士,如果变量本身就是一个字符他就不进行替换。
给你个字符串问你他是不是完全加密了的,是的话输出“YES”,不然“NO”。

这个的话你会发现规律还是很明显的,因为完全加密的字符串的话,你会发现加密到一个种类的字符为 某个字符时,比他小字符肯定已经出现过了因为加密是由小到大的(由a到z)。

比如加密到 b时,b之前一定有a,  aaababaab这个是合法的     但 baa这种是非法的。

#include <iostream>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){

	char str[510];
	map<char,int>Map;
	scanf("%s",str);
	int len = strlen(str);
	bool flag = true;
	for(int i = 0; i < len; i++){
		if(!flag)
			break;
		Map[str[i]] = 1;
		for(int j = 0; j < str[i]-'a'; j++){
			if(Map['a'+j] == 0){
				flag = false;
				break;
			}
		}
	}
	if(flag)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值