#include<stdio.h>
#include<string.h>
int main(){
int i, j, len, n, nump=0, numt=0, locp=0, loct=0, other=0;
char str[110];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",str);
len=strlen(str); nump=0, numt=0, other=0, locp=0, loct=0;
for(j=0;j<len;j++){
if(str[j]=='P'){nump++;locp=j;}
else if(str[j]=='T'){numt++;loct=j;}
else if(str[j]=='A');
else other++;
}
if(nump!=1||numt!=1||other>0||loct-locp<=1)printf("NO\n");
else if((len-loct-1-locp*(loct-locp-2)) ==locp )printf("YES\n");
else printf("NO\n");
}
return 0;
}
PAT-B1003
最新推荐文章于 2021-01-31 16:05:21 发布