。。没啥看的

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.

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;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值