-
Notifications
You must be signed in to change notification settings - Fork 0
/
1003_I_pass.cpp
76 lines (74 loc) · 1.02 KB
/
1003_I_pass.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
#include<iostream>
#include<string.h>
#include <stdio.h>
using namespace std;
int main()
{
int i;
scanf("%d",&i);
int flag1,flag2,flag3,flag4;
char q[100];
char *str=NULL;
for(;i>0;i--)
{
scanf("%s",q);
str=q;
flag1=0;
flag2=0;
flag3=0;
flag4=0;
while(*str != '\0')
{
if((*str)=='A')
{
if(flag1==0)
{
str++;
}
else
{
flag2=1;
str++;
}
}
else if(*str=='P')
{
if(flag4==1)
{
flag3=1;
}
flag1=1;
flag4=1;
str++;
}
else if(*str=='T')
{
if(flag1==1&&flag2==1)
{
flag1=0;
flag2=0;
flag4=0;
str++;
}
else
{
flag3=1;
str++;
}
}
else
{
flag3=1;
str++;
}
}
if(flag3==0)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
}