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 }
  • 相关阅读:
    os.mkdir()与 shutil.rmtree()对文件夹的 创建与删除
    tf.assign_add
    任意图像尺寸变成目标尺寸(包含相应的boxes的变换)
    文件的读取(txt文件)
    tensorflow中使用变量作用域及tf.variable(),tf,getvariable()与tf.variable_scope()的用法
    python中字典的建立
    图像上划凸多边形(convexHull()函数)
    Cypress 系列之----01 安装和使用
    Excel应用----制作二级下拉菜单【转】
    Selenium系列之--08 操作已打开的浏览器
  • 原文地址:https://www.cnblogs.com/weeping/p/6420912.html
Copyright © 2011-2022 走看看