【codeforces 765B】Code obfuscation

【题目链接】:http://codeforces.com/contest/765/problem/B

【题意】

让你把每个变量都依次替换成a,b,c,….d这些字母;
且要按顺序先用a再用b….c.d.e….z

【题解】

模拟一下这个过程就好了;
每次看看最左边那个字母是什么(当然之前已经模拟过的除外);
看看是不是当前枚举到的字母;
不是的话就错误;

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 500+100;

char s[N];
bool bo[N];
int len;

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    scanf("%s",s+1);
    len = strlen(s+1);
    for (char now = 'a';now <= 'z' ;now++)
    {
        int j = -1;
        rep1(i,1,len)
            if (!bo[i])
                {
                    j = i;
                    break;
                }
        if (j==-1)
            return puts("YES"),0;
        if (s[j]!=now)
            return puts("NO"),0;
        rep1(i,1,len)
            if (s[i]==now)
                bo[i] = true;
    }
    puts("YES");
    return 0;
}
posted @ 2017-10-04 18:45  AWCXV  阅读(160)  评论(0编辑  收藏  举报