Codeforces Round #397(Div. 1 + Div. 2 combined)B. Code obfuscation【水题】

原创 2017年02月14日 20:21:30

B. Code obfuscation
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
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.

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.

题目大意:

现在给你一个已经混淆了的字符串,问你是否能够是通过某种字符串得到的。

混淆字符串的机制:对于原串来讲,对于第一种出现的字符,全部替代为a.对于第二种出现的字符,全部替代为b.................依次类推。


思路:


对于出现字母的顺序,肯定是a.b.c.d.e............才是YES的字符串。

那么对于当前字符,如果是之前没出现过的,那么必须是出现过的最大的字母顺序+1才行。


Ac代码:

#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char a[505];
    int vis[505];
    while(~scanf("%s",a))
    {
        memset(vis,0,sizeof(vis));
        int n=strlen(a);
        int now=1;
        int flag=0;
        for(int i=0;i<n;i++)
        {
            if(vis[i]==0)
            {
                if(now!=a[i]-'a'+1)flag=1;
                else
                {
                    for(int j=i;j<n;j++)
                    {
                        if(a[j]==a[i])vis[j]++;
                    }
                }
                now++;
            }
        }
        if(flag==1)printf("NO\n");
        else printf("YES\n");
    }
}








版权声明:0.0小白有写的不好不对的地方请指出~

相关文章推荐

Codeforces Round #397 题解

A. Neverending competitions time limit per test 2 seconds memory limit per test 512 mega...

【Codeforces Round 397】Codeforces 765A-D

模拟、构造
  • sdfzyhx
  • sdfzyhx
  • 2017年02月15日 17:21
  • 316

Codeforces Round #397

A. Neverending competitionsThere are literally dozens of snooker competitions held each year, and te...

CodeForces - 765B Code obfuscation 水题。

B. Code obfuscation time limit per test 2 seconds memory limit per test 512 megabytes ...

iOS_学习代码混淆

人生的道路上有高潮有低谷。 该方法原理是利用脚本生成宏定义,每次随机生成并替换,结合念茜的介绍,有几个地方容易出错,遂整理出来。念茜代码混淆介绍点这里,我本人还参考了这篇文章顺利完成Demo的代码混淆...
  • xin814
  • xin814
  • 2016年05月04日 17:46
  • 2868

【Intel Code Challenge Elimination Round (Div1 + Div2, combined) B】【水题】Verse Pattern

B. Verse Pattern time limit per test 1 second memory limit per test 256 megabytes i...

Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- B. Verse Pattern(水题)

大体题意: 给你n 个数字,给你n 行文章,  问是否每一行的元音字母个数于数字对应?  元音字母是a,e,i,o,u,y 思路: 枚举即可 #include using namespace...

【Codeforces Round 339 (Div 2)B】【水题】Gena's Code 若干10数+1特殊数的乘积

B. Gena's Code time limit per test 0.5 seconds memory limit per test 256 megabytes ...

Codeforces Round #397(Div. 1 + Div. 2 combined)E. Tree Folding【思维+Dfs】dalao们的解法真巧妙系列QAQ

E. Tree Folding time limit per test 2 seconds memory limit per test 512 megabytes input ...

Codeforces Round #397 (Div. 1 + Div. 2 combined) D. Artsem and Saunders 映射+构造

题意:给出一个函数f(x) 属于[1,x],然后要求确定一个数m,使x属于[1,n],g[x]属于[1,m], x输入[1,m] h[x]属于[1,n], 当存在m时,求m最小时的gx和hx。 映射+...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Codeforces Round #397(Div. 1 + Div. 2 combined)B. Code obfuscation【水题】
举报原因:
原因补充:

(最多只允许输入30个字)