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形式说明服务提供什么样的方法 – 如何调用. ...
随机推荐
- 一,PHP会话机制---cookie
1, 什么是会话 会话可简单理解为:用户打开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 2, cookie技术 cookie(小甜饼)是客户端技 ...
- linux crontab 实现每秒执行的实例
linux crontab 命令,最小的执行时间是一分钟.如需要在小于一分钟内重复执行,可以有两个方法实现. 1.使用延时来实现每N秒执行 原理:通过延时方法 sleep N 来实现每N秒执行. 创 ...
- eclipse代码中使用到Launcher获取类加载器,找不到启动器类。
解决:移除系统依赖的jar包,重新导入. 只需要在project build path中先移除JRE System Library,再添加库JRE System Library,重新编译后就一切正常了 ...
- 组件基础—Vue学习笔记
ammm学习Vue有好几天了,今天遇到难点所以打算写一点随笔加深印象. 一.首先最简单的创建组件 1全局组件 Vue.component() Vue.component('hello',{ tem ...
- js之math 对象
Math 对象是js中使用数学公式计算的便捷方法,其方法运行起来比直接写的js运行是对要更快 1.Math.min(一组数值) 该方法可以比较一组数值的大小,并且返回较小的数值 用法: Math.m ...
- 剑指offer二十一之栈的压入、弹出序列
一.题目 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序 ...
- jboss8+EJB3+MDB Queue
1)在使用jboss8即WildFly进行MDB的试验时首先要在jboss8中配置jms 队列. 我使用的是修改配置文件的方式配置Jms Queue队列. 进入jboss8 安装目录的standalo ...
- Java之集合(一)接口及抽象类
转载请注明源出处:http://www.cnblogs.com/lighten/p/7278655.html 1.前言 从本章开始介绍Java的集合类,这些类主要存在于java.util包下,该系列基 ...
- Filter应用之-自动登录
自动登录,是为了帮助用户多次使用这个网页时,不用再次输入用户名和密码就可以登录. 是指用户将用户的登录信息,人,保存到本地的文件中Cookie中. Name,value – 声明时 new Cooki ...
- javac后期需要重点阅读的类
(1)Annotate (300行) Enter annotations on symbols. Annotations accumulate in a queue,which is processe ...