-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1002.cpp
36 lines (30 loc) · 853 Bytes
/
1002.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
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n; cin>>n;
while(n--)
{
string str;
cin>>str;
int pos_p=-1,pos_t=-1,cnt_p=0,cnt_t=0,cnt_other=0;
for(int i=0;i<str.size();i++)
{
if(str[i]=='P') {cnt_p++;pos_p=i;}
else if(str[i]=='T'){cnt_t++;pos_t=i;}
else if(str[i]!='A') {cnt_other++;}
}
bool ans = true;
if(cnt_p>1||cnt_t>1||cnt_other>0) ans=false;
else
{
int cnt_a=pos_t-pos_p-1;//PT Ö®¼äAµÄ¸öÊý
if(cnt_a<=0) ans=false;
else if((str.size()-1-pos_t)!=cnt_a*pos_p) ans=false;
}
if(ans==true) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
system("pause");
}