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 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".
Sample Input
abacaba
Sample Output
YES
Hint
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……
然后这样混淆下去。
现在给你一个代码,里面只有变量,把空格和换行符都删去之后,问你这个代码可不可能是混淆之后的代码。
题解:
照着题意模拟就好了。
代码
#include<bits/stdc++.h>
using namespace std;
int now = 0;
int vis[26];
int main()
{
string s;
cin>>s;
for(int i=0;i<s.size();i++){
if(vis[s[i]-'a'])continue;
if(now==(int)(s[i]-'a')){
vis[s[i]-'a']=1;
now++;
continue;
}
cout<<"NO"<<endl;
return 0;
}
cout<<"YES"<<endl;
}
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) 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) B - Code obfuscation
地址:http://codeforces.com/contest/765/problem/B 题目: B. Code obfuscation time limit per test 2 seconds ...
- 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 ...
随机推荐
- bzoj千题计划178:bzoj2425: [HAOI2010]计数
http://www.lydsy.com/JudgeOnline/problem.php?id=2425 题意转化: 给定一个集合S,求S的全排列<给定排列 的排列个数 从最高位开始逐位枚举确定 ...
- 【原创】backbone1.1.0源码解析之View
作为MVC框架,M(odel) V(iew) C(ontroler)之间的联系是必不可少的,今天要说的就是View(视图) 通常我们在写逻辑代码也好或者是在ui组件也好,都需要跟dom打交道,我们 ...
- HDU 1241 Oil Deposits DFS搜索题
题目大意:给你一个m*n的矩阵,里面有两种符号,一种是 @ 表示这个位置有油田,另一种是 * 表示这个位置没有油田,现在规定相邻的任意块油田只算一块油田,这里的相邻包括上下左右以及斜的的四个方向相邻的 ...
- 勒索软件Locky、Tesalcrypt等使用了新的工具躲避检测
勒索软件Locky.Tesalcrypt等使用了新的工具躲避检测 今天我们发现Locky勒索软件家族使用一种新的工具来躲避检测,并且可能已经感染了很多节点. 自从我们通过AutoFocus智能威胁分析 ...
- 使用java如何操作elasticsearch?简单示例。
在线API:https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.4/transport-client.html教程:http ...
- Java 语言多态性
https://www.ibm.com/developerworks/cn/java/java-language-polymorphism/index.html 定义多态性 多态性是面向对象编程中的一 ...
- 【转】使用import scope解决maven继承(单)问题
http://blog.csdn.net/mn960mn/article/details/50894022 测试环境 maven 3.3.9 想必大家在做SpringBoot应用的时候,都会有如下代码 ...
- vs2017 Remote Debugger远程调试目录
默认目录:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Remote Debugger
- Mac 命令行安装 dmg文件
1.安装dmg文件 hdiutil attach jdk-9.0.1_osx-x64_bin.dmg 会挂载在 /Volumes 目录下 2.安装pkg文件(可以 man installer 查看命令 ...
- 驱动程序vmci.sys版本不正确。请尝试重新安装 VMware
今天在测试一台服务器,安装在虚拟机里面,但是发现在安装后,重启了一下电脑,出现了这个错误: 无法获取 vmci 驱动程序版本: 句柄无效.驱动程序 vmci.sys 版本不正确.请尝试重新安装 VMw ...