forked from zhuli19901106/poj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPOJ1126(AC).cpp
81 lines (72 loc) · 912 Bytes
/
POJ1126(AC).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int idx;
char s[1000];
int len;
bool suc;
void check(const char s[], int i)
{
if(!suc){
return;
}
if(i >= len || idx >= len){
suc = false;
return;
}
switch(s[i]){
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
idx = i + 1;
return;
case 'C':
case 'D':
case 'E':
case 'I':
idx = i + 1;
check(s, idx);
if(idx >= len){
suc = false;
return;
}else{
check(s, idx);
return;
}
case 'N':
idx = i + 1;
check(s, idx);
return;
default:
suc = false;
return;
}
}
int main()
{
while(scanf("%s", s) == 1){
len = strlen(s);
idx = 0;
suc = true;
check(s, 0);
if(idx != len){
suc = false;
}
if(suc){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}