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小白有写的不好不对的地方请指出~

iOS_学习代码混淆

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

CodeForces 765B Code obfuscation

题目链接:http://codeforces.com/contest/765/problem/B 题意:告诉你一种编码方式,就是给你一个字符串,然后把它变成另一个字符串,如果第一个出现的字符就把他变...
  • Richie_ll
  • Richie_ll
  • 2017年03月27日 18:21
  • 216

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

B. Code obfuscation time limit per test 2 seconds memory limit per test 512 megabytes inp...
  • mengxiang000000
  • mengxiang000000
  • 2017年02月14日 20:21
  • 459

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)A+B

A. Gotta Catch Em’ All!time limit per test:1 secondmemory limit per test:256 megabytesinput:standard...
  • qq_33183401
  • qq_33183401
  • 2017年01月16日 17:12
  • 243

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A. Gotta Catch Em' All!(水题)

题目链接:http://codeforces.com/contest/757/problem/AA. Gotta Catch Em’ All! time limit per test1 second...
  • qq_32866009
  • qq_32866009
  • 2017年01月13日 09:17
  • 200

cf397 B. Code obfuscation

B. Code obfuscation time limit per test2 seconds memory limit per test512 megabytes inputstandard...
  • zxy160
  • zxy160
  • 2017年03月13日 19:35
  • 341

iOS代码混淆总结

转载自: http://www.2cto.com/kf/201703/611865.html iOS代码混淆总结 做代码混淆需要六大步骤 1:首先你要创建一个工程...
  • chenyong05314
  • chenyong05314
  • 2017年07月11日 12:15
  • 210

Codeforces Round #258 (Div. 2)-(A,B,C,D,E)

A:Game With Sticks 水题。。。每次操作,都会拿走一个横行,一个竖行。 所以一共会操作min(横行,竖行)次。 #include #include #include #include ...
  • rowanhaoa
  • rowanhaoa
  • 2014年07月25日 14:39
  • 1484

Codeforces Round #378 (Div. 2) E. Sleep in Class

链接:http://codeforces.com/contest/733/problem/E 题意:给一个只含'U'和'D'的字符串,U表示向右走,D表示向左走。每个格子踩一次之后翻转(U变D,D变...
  • Fsss_7
  • Fsss_7
  • 2016年11月15日 13:48
  • 359

CF 397 B. Code obfuscation

B. Code obfuscation time limit per test 2 seconds memory limit per test 512 megabytes ...
  • fengkuangdewoniudada
  • fengkuangdewoniudada
  • 2017年02月15日 20:22
  • 113
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Codeforces Round #397(Div. 1 + Div. 2 combined)B. Code obfuscation【水题】
举报原因:
原因补充:

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