Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined) B

Source: Internet
Author: User

Description

Kostya likes Codeforces contests very much. However, he is very disappointed, the He solutions is frequently hacked. That's why he decided to obfuscate (intentionally do less readable) his code before upcoming contest.

To obfuscate the code, Kostya first looks on 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 have not been replaced yet, and replace s all it occurrences with b, and so on. Kostya is well-mannered, so he doesn ' t use any one-letter names before obfuscation. Moreover, there is at the most of the unique identifiers in his programs.

You is 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 中文版 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 is "numberstring number character number string numb Er ". Here are Kostya would obfuscate the program:

    • Replace all occurences of number with A, the result would is "a string a character a string a",
    • Replace all occurences of string with B, the result would is "a B a character a b a",
    • Replace all occurences of character with C, the result would is "a B a c a B a",
    • All identifiers has been replaced, thus the obfuscation is finished.

Test instructions: Someone tries to replace the variable name with a lowercase letter, replace the first variable name with a and the same variable from a, then replace the variable name with b instead of a, and so on, asking if the last given string is compliant

Solution: The first letter must be a, and then appear in turn b,c,d, recurrence is skipped, there is an interrupt description does not meet

1#include <bits/stdc++.h>2 using namespacestd;3 strings;4 intMain ()5 {6map<Char,int>Q;7map<Char,int>:: iterator it;8Cin>>s;9     if(s[0]!='a')Ten     { Onecout<<"NO"; A     } -     Else -     { the         intflag='a'; -          for(intI=0; I<s.length (); i++) -         { -             if((int) s[i]==flag) +             { -flag++; +q[s[i]]=1; A             } at             Else if(Q[s[i]]) -             { -                 Continue; -             } -             Else -             { incout<<"NO"; -                 return 0; to             } +         } -cout<<"YES"; the     } *     return 0; $}

Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined) B

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.