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 ;
}
最新文章
- iOS开发之Alamofire源码解析前奏--NSURLSession全家桶
- LVS负载平衡集群(没成型)
- AEAI BPM流程集成平台V3.0.2版本开源发布
- 后台API服务的设计考虑
- WCF并发控制与实例模式
- table动态添加删除一行和改变标题
- sql 表连接 join
- 闲置小U盘变身最强大路由器
- outlet删除不完全
- php函数声明的简单实例
- 零基Github Page个人博客建立教程无限的自由流动
- WAMPServer多站点配置方法
- python网络爬虫与信息提取 学习笔记day2
- objective-c随机数+日期格式显示一例
- BZOJ_1085_[SCOI2005]骑士精神_IDDFS
- HelloPython
- 读《Tooth-Marked Tongue Recgnition Using Multiple Instance Learning and CNN Features》
- Linux 常用命令笔记-2
- LeetCode算法题-Implement Queue Using Stacks(Java实现)
- [NOI2017]游戏(2-SAT)