Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B - Code obfuscation
地址:http://codeforces.com/contest/765/problem/B
题目:
2 seconds
512 megabytes
standard input
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.
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.
If this program can be a result of Kostya's obfuscation, print "YES" (without quotes), otherwise print "NO".
abacaba
YES
jinotega
NO
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.
思路:如果合法,出现的最大字母依次是a,b,c,d....
直接扫一遍即可
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e5+;
const int mod=1e9+; char ss[K],mx='a'-;
int ff;
int main(void)
{
cin>>ss;
for(int i=,len=strlen(ss);i<len;i++)
if(ss[i]<=mx)
;
else if(ss[i]==mx+)
mx++;
else
ff=;
if(ff)
printf("NO\n");
else
printf("YES\n");
return ;
}
Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B - Code obfuscation的更多相关文章
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B. Code obfuscation 水题
B. Code obfuscation 题目连接: http://codeforces.com/contest/765/problem/B Description Kostya likes Codef ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A B C D 水 模拟 构造
A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) F. Souvenirs 线段树套set
F. Souvenirs 题目连接: http://codeforces.com/contest/765/problem/F Description Artsem is on vacation and ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding 拓扑排序
E. Tree Folding 题目连接: http://codeforces.com/contest/765/problem/E Description Vanya wants to minimiz ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders 数学 构造
D. Artsem and Saunders 题目连接: http://codeforces.com/contest/765/problem/D Description Artsem has a fr ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C. Table Tennis Game 2 水题
C. Table Tennis Game 2 题目连接: http://codeforces.com/contest/765/problem/C Description Misha and Vanya ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A. Neverending competitions 水题
A. Neverending competitions 题目连接: http://codeforces.com/contest/765/problem/A Description There are ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding
地址:http://codeforces.com/contest/765/problem/E 题目: E. Tree Folding time limit per test 2 seconds mem ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders
地址:http://codeforces.com/contest/765/problem/D 题目: D. Artsem and Saunders time limit per test 2 seco ...
随机推荐
- [Idea Fragments] PostScript for 3D Print??
今天看到一篇关于PostScript的文章<编程珠玑番外篇-P PostScript 语言里的珠玑>,尤其是篇尾的这段话,让我对3D Print浮想联翩: 因为 PostScript 语言 ...
- 如何给RecyclerView加上滚动条--现在就教你
时隔许久,我又要更博了,含蓄的话不多说了,今天我们的主题是这个RecyclerView.至于为什么要加个scrollBar?因为我的业务需求是需要一个实现成这样的, 效果图:(可能看起来比较粗糙,但功 ...
- Tomcat nginx log日志按天分割切割
利用 Linux 自带的 logrotate 工具来实现按天切割日志.下方已 centos 7 系统为例来实践讲解. 原理 Logrotate是基于CRON来运行的,其脚本是/etc/cron.dai ...
- 设置EntityFramework中decimal类型数据精度
EF中默认的decimal数据精度为两位数,当我们数据库设置的精度大于2时,EF将只会保留到2为精度. e.g. 2.1999将会被保存为2.20 网上找到常见的方法为重写DbContext的OnMo ...
- IPMI特点和功能
IPMI独立于操作系统外自行运作,并容许管理者即使在缺少操作系统或系统管理软件.或受监控的系统关机但有接电源的情况下仍能远程管理系统. ipmi可以实现对机器的操作举例如下: 开机,关机,重启,查看机 ...
- EntityFramework :数据库创建
控制数据库的位置 默认情况下,数据库是创建在localhost\SQLEXPRESS服务器上,并且默认的数据库名为命名空间+context类名,例如我们前面的BreakAway.BreakAwayCo ...
- jvm相关參数,调优
常见的jvm參数例如以下 -Xmx1024m:设置JVM最大可用内存为1024M. -Xms1024m:设置JVM初始内存为1024m. 此值能够设置与-Xmx同样,以避免每次垃圾回收完毕后JVM又一 ...
- 存一些可能会用得到的vue的UI框架
VUX 项目主页:https://vux.li/#/ github地址:https://github.com/airyland/vux element UI(饿了么后台) Element 是由饿了么U ...
- HttpURLConnection 当作请求调用接口不带返回参数的工具类
package cn.smartercampus.core.util; import java.io.BufferedReader; import java.io.InputStream; impor ...
- phantomjs学习之网页访问测速
1.编写loadpage2.js文件: loadpage2.js var page = require('webpage').create(), system = require('system'), ...