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.
Kostya非常喜欢codeforces竞赛。然而,他非常失望,他的解决方案经常被黑客攻击。这就是为什么他决定混淆(故意使不可读)在即将到来的比赛他的代码。
混淆代码,Kostya首先用在自己的节目中第一个变量名和一个单一的符号替换所有出现的,然后他看了看二变量名称没有被取代,取代B的所有事件,等等。Kostya是彬彬有礼的,所以他不在混淆使用任何一个字母的名字。此外,他的程序中最多有26个唯一标识符。
给出了一些程序的标识符列表,其中包括空格和换行符。看看这个程序可以因Kostya的困惑。
首先第一个字母必须是a 否则不行 把最大值记录下来,然后看她后一个是不是比他大,如果大并且只大一更新最大值否则输出no,如果小于等于最大值不用管(因为既然有了最大值 说明a-最大值都有了,如果比最大值小说明前面出现了 就不用管了)
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
int t=0,i,c,x=0;
char a[500],b;
gets(a);
c=strlen(a);
if(a[0]!='a')
printf("NO\n");
else
{
b='a';
for(i=1; i<=c-1; i++)
{
if(a[i]>b&&a[i]==b+1)
b=a[i];
if(a[i]>b&&a[i]!=b+1)
{
x=1;
printf("NO\n");
break;
}
}
if(x==0)
printf("YES\n");
}
return 0;
}