zoukankan      html  css  js  c++  java
  • Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B

    地址:http://codeforces.com/contest/765/problem/B

    题目:

    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,c,d....

      直接扫一遍即可

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 #define MP make_pair
     6 #define PB push_back
     7 typedef long long LL;
     8 typedef pair<int,int> PII;
     9 const double eps=1e-8;
    10 const double pi=acos(-1.0);
    11 const int K=1e5+7;
    12 const int mod=1e9+7;
    13 
    14 char ss[K],mx='a'-1;
    15 int ff;
    16 int main(void)
    17 {
    18    cin>>ss;
    19    for(int i=0,len=strlen(ss);i<len;i++)
    20     if(ss[i]<=mx)
    21         ;
    22     else if(ss[i]==mx+1)
    23         mx++;
    24     else
    25         ff=1;
    26     if(ff)
    27         printf("NO
    ");
    28     else
    29         printf("YES
    ");
    30     return 0;
    31 }
  • 相关阅读:
    xcode12.2上运行平板IOS15.1
    发行版本崩溃,调试版本正常
    freetype安装使用
    码流的宽高和裁剪信息
    Xcode 沙盒选项
    【最新揭秘】百度快收权限如何获得,教你一周快速获得快收权限
    destoon提示http 403 forbidden解决方法
    他们口中的百度SEO快排发包参数到底是什么?
    destoon内容页调取相关内容标签
    destoon百度小程序主动推送插件
  • 原文地址:https://www.cnblogs.com/weeping/p/6420912.html
Copyright © 2011-2022 走看看