-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1003.c
56 lines (51 loc) · 1.06 KB
/
1003.c
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
#include<stdio.h>//18分
int pre(char s[]);
int main()
{
char str[100];
int N;
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%s", str);
if(i != 0){
printf("\n");
}
if(pre(str)){
printf("YES");
}else{
printf("NO");
}
}
return 0;
}
int pre(char s[]){
int n[3] = {0};
int p = 0, t = 0;
for(int i = 0, j = 0; s[i] != '\0'; i++){
if(s[i] == 'A' && p ==0 && t == 0){
n[j]++;
continue;
}else if(s[i] == 'P' && p == 0 && t == 0){
p++;
j++;
}else if(s[i] == 'A' && p == 1 && t == 0){
n[j]++;
continue;
}else if(s[i] == 'T' && p == 1 && t == 0){
t++;
j++;
continue;
}else if(s[i] == 'A' && p ==1 && t == 1){
n[j]++;
continue;
}else{
return 0;
}
}
if(n[1] == 0){
return 0;
}else if(n[2] != n[1] * n[0]){
return 0;
}
return 1;
}