Central Europe Regional Contest 2012 Problem C: Chemist’s vows

http://acm.hunnu.edu.cn/online/problem_pdf/CERC2012/C.pdf

HUNNU11372

模拟题,直接暴力既可,比赛的时候想过这种方法,但是没敢动手,唉,以后要勇于尝试

 

 

#include <stdio.h>
#include <string.h>
using namespace std;

char str[50005];

int main()
{
    int t,len,i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%s",str);
        len = strlen(str);
        int flag = 1,flag1 = 0,flag2 = 0;
        for (i=0; i<len; i++)
        {
            flag2 = flag1;
            flag1 = flag;
            flag = 0;
            if (flag1)
            {
                if (str[i]=='b') flag = 1;
                if (str[i]=='c') flag = 1;
                if (str[i]=='f') flag = 1;
                if (str[i]=='h') flag = 1;
                if (str[i]=='i') flag = 1;
                if (str[i]=='k') flag = 1;
                if (str[i]=='n') flag = 1;
                if (str[i]=='o') flag = 1;
                if (str[i]=='p') flag = 1;
                if (str[i]=='s') flag = 1;
                if (str[i]=='u') flag = 1;
                if (str[i]=='v') flag = 1;
                if (str[i]=='w') flag = 1;
                if (str[i]=='y') flag = 1;
            }
            if (flag2)
            {
                if (str[i-1]=='a' and str[i]=='c') flag = 1;
                if (str[i-1]=='a' and str[i]=='g') flag = 1;
                if (str[i-1]=='a' and str[i]=='l') flag = 1;
                if (str[i-1]=='a' and str[i]=='m') flag = 1;
                if (str[i-1]=='a' and str[i]=='r') flag = 1;
                if (str[i-1]=='a' and str[i]=='s') flag = 1;
                if (str[i-1]=='a' and str[i]=='t') flag = 1;
                if (str[i-1]=='a' and str[i]=='u') flag = 1;
                if (str[i-1]=='b' and str[i]=='a') flag = 1;
                if (str[i-1]=='b' and str[i]=='e') flag = 1;
                if (str[i-1]=='b' and str[i]=='h') flag = 1;
                if (str[i-1]=='b' and str[i]=='i') flag = 1;
                if (str[i-1]=='b' and str[i]=='k') flag = 1;
                if (str[i-1]=='b' and str[i]=='r') flag = 1;
                if (str[i-1]=='c' and str[i]=='a') flag = 1;
                if (str[i-1]=='c' and str[i]=='d') flag = 1;
                if (str[i-1]=='c' and str[i]=='e') flag = 1;
                if (str[i-1]=='c' and str[i]=='f') flag = 1;
                if (str[i-1]=='c' and str[i]=='l') flag = 1;
                if (str[i-1]=='c' and str[i]=='m') flag = 1;
                if (str[i-1]=='c' and str[i]=='n') flag = 1;
                if (str[i-1]=='c' and str[i]=='o') flag = 1;
                if (str[i-1]=='c' and str[i]=='r') flag = 1;
                if (str[i-1]=='c' and str[i]=='s') flag = 1;
                if (str[i-1]=='c' and str[i]=='u') flag = 1;
                if (str[i-1]=='d' and str[i]=='b') flag = 1;
                if (str[i-1]=='d' and str[i]=='s') flag = 1;
                if (str[i-1]=='d' and str[i]=='y') flag = 1;
                if (str[i-1]=='e' and str[i]=='r') flag = 1;
                if (str[i-1]=='e' and str[i]=='s') flag = 1;
                if (str[i-1]=='e' and str[i]=='u') flag = 1;
                if (str[i-1]=='f' and str[i]=='e') flag = 1;
                if (str[i-1]=='f' and str[i]=='l') flag = 1;
                if (str[i-1]=='f' and str[i]=='m') flag = 1;
                if (str[i-1]=='f' and str[i]=='r') flag = 1;
                if (str[i-1]=='g' and str[i]=='a') flag = 1;
                if (str[i-1]=='g' and str[i]=='d') flag = 1;
                if (str[i-1]=='g' and str[i]=='e') flag = 1;
                if (str[i-1]=='h' and str[i]=='e') flag = 1;
                if (str[i-1]=='h' and str[i]=='f') flag = 1;
                if (str[i-1]=='h' and str[i]=='g') flag = 1;
                if (str[i-1]=='h' and str[i]=='o') flag = 1;
                if (str[i-1]=='h' and str[i]=='s') flag = 1;
                if (str[i-1]=='i' and str[i]=='n') flag = 1;
                if (str[i-1]=='i' and str[i]=='r') flag = 1;
                if (str[i-1]=='k' and str[i]=='r') flag = 1;
                if (str[i-1]=='l' and str[i]=='a') flag = 1;
                if (str[i-1]=='l' and str[i]=='i') flag = 1;
                if (str[i-1]=='l' and str[i]=='r') flag = 1;
                if (str[i-1]=='l' and str[i]=='u') flag = 1;
                if (str[i-1]=='l' and str[i]=='v') flag = 1;
                if (str[i-1]=='m' and str[i]=='d') flag = 1;
                if (str[i-1]=='m' and str[i]=='g') flag = 1;
                if (str[i-1]=='m' and str[i]=='n') flag = 1;
                if (str[i-1]=='m' and str[i]=='o') flag = 1;
                if (str[i-1]=='m' and str[i]=='t') flag = 1;
                if (str[i-1]=='n' and str[i]=='a') flag = 1;
                if (str[i-1]=='n' and str[i]=='b') flag = 1;
                if (str[i-1]=='n' and str[i]=='d') flag = 1;
                if (str[i-1]=='n' and str[i]=='e') flag = 1;
                if (str[i-1]=='n' and str[i]=='i') flag = 1;
                if (str[i-1]=='n' and str[i]=='o') flag = 1;
                if (str[i-1]=='n' and str[i]=='p') flag = 1;
                if (str[i-1]=='o' and str[i]=='s') flag = 1;
                if (str[i-1]=='p' and str[i]=='a') flag = 1;
                if (str[i-1]=='p' and str[i]=='b') flag = 1;
                if (str[i-1]=='p' and str[i]=='d') flag = 1;
                if (str[i-1]=='p' and str[i]=='m') flag = 1;
                if (str[i-1]=='p' and str[i]=='o') flag = 1;
                if (str[i-1]=='p' and str[i]=='r') flag = 1;
                if (str[i-1]=='p' and str[i]=='t') flag = 1;
                if (str[i-1]=='p' and str[i]=='u') flag = 1;
                if (str[i-1]=='r' and str[i]=='a') flag = 1;
                if (str[i-1]=='r' and str[i]=='b') flag = 1;
                if (str[i-1]=='r' and str[i]=='e') flag = 1;
                if (str[i-1]=='r' and str[i]=='f') flag = 1;
                if (str[i-1]=='r' and str[i]=='g') flag = 1;
                if (str[i-1]=='r' and str[i]=='h') flag = 1;
                if (str[i-1]=='r' and str[i]=='n') flag = 1;
                if (str[i-1]=='r' and str[i]=='u') flag = 1;
                if (str[i-1]=='s' and str[i]=='b') flag = 1;
                if (str[i-1]=='s' and str[i]=='c') flag = 1;
                if (str[i-1]=='s' and str[i]=='e') flag = 1;
                if (str[i-1]=='s' and str[i]=='g') flag = 1;
                if (str[i-1]=='s' and str[i]=='i') flag = 1;
                if (str[i-1]=='s' and str[i]=='m') flag = 1;
                if (str[i-1]=='s' and str[i]=='n') flag = 1;
                if (str[i-1]=='s' and str[i]=='r') flag = 1;
                if (str[i-1]=='t' and str[i]=='a') flag = 1;
                if (str[i-1]=='t' and str[i]=='b') flag = 1;
                if (str[i-1]=='t' and str[i]=='c') flag = 1;
                if (str[i-1]=='t' and str[i]=='e') flag = 1;
                if (str[i-1]=='t' and str[i]=='h') flag = 1;
                if (str[i-1]=='t' and str[i]=='i') flag = 1;
                if (str[i-1]=='t' and str[i]=='l') flag = 1;
                if (str[i-1]=='t' and str[i]=='m') flag = 1;
                if (str[i-1]=='x' and str[i]=='e') flag = 1;
                if (str[i-1]=='y' and str[i]=='b') flag = 1;
                if (str[i-1]=='z' and str[i]=='n') flag = 1;
                if (str[i-1]=='z' and str[i]=='r') flag = 1;
            }
        }
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}

你可能感兴趣的:(CERC2012,hunnu)