zoukankan      html  css  js  c++  java
  • CodeForces765B

    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.
     1 //2017-02-14
     2 #include <iostream>
     3 #include <cstdio>
     4 #include <cstring>
     5 
     6 using namespace std;
     7 
     8 int book[30];
     9 
    10 int main()
    11 {
    12     string S;
    13     char cur_max;
    14     bool fg;
    15     while(cin>>S)
    16     {
    17         fg = true;
    18         memset(book, 0, sizeof(book));
    19         for(int i = 0; i < S.length(); i++)
    20               book[S[i]-'a']++;
    21         for(int i = 1; i < 26; i++)
    22               if(book[i]!=0 && book[i-1]==0)
    23             {
    24                 fg = false;
    25                 break;
    26             }
    27         cur_max = S[0];
    28         if(cur_max != 'a')fg = false;
    29         for(int i = 1; i < S.length(); i++)
    30         {
    31             if(S[i]>cur_max && S[i]-cur_max==1)cur_max = S[i];
    32             else if(S[i]>cur_max && S[i]-cur_max>1){
    33                 fg = false;
    34                 break;
    35             }
    36         }
    37         if(fg)cout<<"YES"<<endl;
    38         else cout<<"NO"<<endl;
    39     }
    40 
    41     return 0;
    42 }
  • 相关阅读:
    nginx 、tomcat 配置表单附件大小限制
    清理redis服务器数据
    tomcat 8.5.55 webapps 无法部署应用目录 org.apache.catalina.startup.HostConfig.deployDirectory
    redis + tomcat8.5 session共享
    linux tar 打包
    mysql ORDER BY RAND() 语句优化
    解决Linux下程序端口占用问题
    javamail邮件发送开发中SharedByteArrayInputStream类找不到的错误(java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream)
    ansible判定文件或者文件夹是否存在
    ansible应用
  • 原文地址:https://www.cnblogs.com/Penn000/p/6399385.html
Copyright © 2011-2022 走看看