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形式说明服务提供什么样的方法 – 如何调用. ...
随机推荐
- 操作实践题 - HTML 列表综合应用
通过对列表的综合应用,编写如下效果网页: 解答: <html> <head> <title>操作实践题</title> <meta http-eq ...
- 打开SVN server图形化管理界面
来源:http://blog.csdn.net/u013495063/article/details/76796079 1.在ViaualSVN Service的安装目录:C:\Program Fil ...
- 关于使用Iscroll.js异步加载数据后不能滑动到最底端的问题解决方案
关于使用Iscroll.js异步加载数据后不能滑动到最底端,拉到最下边又弹回去的问题困扰了我老半天,相信很多朋友都遇到了.我刚好不小心解决了,和大家分享一下.由于各种忙,下边就直接上代码吧. (前提是 ...
- jmeter-linux下运行
1.2 在命令行下运行脚本 将1.1中的脚本保存,在编辑是随时可以保存,保存后是一个jmx格式的文件(如图),这个就是要在命令行下运行的脚本(作为参数运行).这个脚本文件可以不包含1.1中第四和第五步 ...
- php 词法分析,语法分析
php的词法分析 可以理解为 通过一定的规则,把输入的代码 区分出哪些是 是$开头的变量, 哪些是 以两个单引号括起来的字符串,哪些是以两个双引号括起来的字符串 等等, 这些区分出来的东西 称为tok ...
- RHCE 学习结构
本文内容为本站的 blog 链接 第一章 安装初体验 第二章 访问系统 2.1 基于图形化界面访问 2.2 基于文本访问 2.3 用户管理 第三章 文件系统 3.1 Linux 文件系统 ...
- 渐进增强与优雅降级 && css3中普通属性和前缀属性的书写顺序
什么是渐进增强与优雅降级? 服务器和浏览器是不同的.当服务器有新版本时,开发人员直接使用新版本的服务器提供服务即可:但是浏览器端,不同的用户使用的浏览器版本不同,型号差异大,我们不可能让用户强制更新 ...
- JavaMail之-通过邮件激活账号
关键点就在于: 根据用户的给出的email,给这个email发送一个邮件.这个邮件中应该带有一个激活码?(32位UUID,64位UUID). 大概步骤: 1, 注册功能 - 只要用户注册成功,就给他 ...
- Android studio 获取每次编译apk时的日期
项目中需要获取apk的编译日期,首先肯定是用手动的方式获取,但这样容易遗忘,怎么样通过代码的方式获取呢? 其实android 为我们提供了一个BuildConfig的类,android 每次编译的时候 ...
- css 设置滚动条的样式
/*移动端显示滚动条*/ .layui-table-body::-webkit-scrollbar { -webkit-appearance: none; } .layui-table-body::- ...