CodeForces765B
B. Code obfuscation
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.
//2017-02-14
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int book[]; int main()
{
string S;
char cur_max;
bool fg;
while(cin>>S)
{
fg = true;
memset(book, , sizeof(book));
for(int i = ; i < S.length(); i++)
book[S[i]-'a']++;
for(int i = ; i < ; i++)
if(book[i]!= && book[i-]==)
{
fg = false;
break;
}
cur_max = S[];
if(cur_max != 'a')fg = false;
for(int i = ; i < S.length(); i++)
{
if(S[i]>cur_max && S[i]-cur_max==)cur_max = S[i];
else if(S[i]>cur_max && S[i]-cur_max>){
fg = false;
break;
}
}
if(fg)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
} return ;
}
CodeForces765B的更多相关文章
- WSDL协议简单介绍
WSDL – WebService Description Language – Web服务描述语言 通过XML形式说明服务在什么地方-地址. 通过XML形式说明服务提供什么样的方法 – 如何调用. ...
随机推荐
- flask之信号
Flask框架中的信号基于blinker,其主要就是让开发者可是在flask请求过程中定制一些用户行为. pip3 install blinker 1. 内置信号 request_started = ...
- Dynamic Programming-650. 2 Keys Keyboard
Initially on a notepad only one character 'A' is present. You can perform two operations on this not ...
- ZZNU 2076(退役学长最后的神功 zz题)
题目链接:http://acm.zznu.edu.cn/problem.php?pid=2076 输入一个T表示有T个样例每组实例一个整数n(0〈n〈1000接下来输入2*n个数字,代表一个2*n的矩 ...
- Nexus3.6 window版私服搭建 安装、配置教程
1.本地环境配置(Nexus3.6支持jdk版本1.6.1.7.1.8) 1.1.官网下载地址:https://www.sonatype.com/download-oss-sonatype ...
- 再看javascript执行上下文、变量对象
突然看到一篇远在2010年的老文,作者以章节的形式向我们介绍了ECMA-262-3的部分内容,主要涉及到执行上下文.变量对象.作用域.this等语言细节.内容短小而精悍,文风直白而严谨,读完有酣畅淋漓 ...
- 神策Loagent数据收集 windows部署的坑
部署可以修改bin文件夹下的bat文件.. java改为javaw..无窗口运行 重新启动的时候..要保证上次运行到的日志文件要还在..或者同名文件.. 保证要比之前的文件大些..所以最好是之前的文件 ...
- HashMap、HashSet、LinkedHashSet、TreeSet的关系
类图及说明如下:
- Postman安装及简介
Postman简介 不管web自动化测试还是APP自动化端,测试过程中都会涉及到接口测试.接口测试分为服务器端测试和客户端测试.今天给大家介绍一个测试服务器端的小工具--Postman.它可以构造各类 ...
- Mysql 断电数据损毁恢复
error log: Database page corruption on disk or a failed 处理: /etc/my.cnf 设置 innodb_force_recovery = 6 ...
- webpack4重新梳理一下2
上一篇已经实现了webpack的基本打包操作,但是并没有使用配置文件,而是使用 CLI 来实现打包. 配置文件 // webpack.config.js module.exports = { //入口 ...