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 }
  • 相关阅读:
    ESP8266 SDK开发
    硬件基础知识和典型应用-Altium Designer 加载SETP文件设置3D封装
    Golang 协程控制关闭
    Redis主从集群切换数据丢失问题
    Goroutine(协程)的理解
    堆和栈的概念和区别
    golang goroutine实现_golang中的Mutex设计原理详解(一)
    OpenCV cv::Mat.type() 以及各类型数据转换
    python 处理json
    python 文件|路径 常用方法
  • 原文地址:https://www.cnblogs.com/weeping/p/6420912.html
Copyright © 2011-2022 走看看