1003 我要通过!
输入样例
8
PAT
PAAT
AAPATAA
AAPAATAAAA
xPATx
PT
Whatever
APAAATAA
输出样例
YES
YES
YES
YES
NO
NO
NO
NO
代码如下:
#判别函数
def judge(s):
#条件1
for i in range(len(s)):
if s[i] not in 'PAT':
return '答案错误'
#条件2和3
a = s.find('P')
b = s.find('T')
if a+1==b or a==-1 or b==-1:
return '答案错误'
if a*(b-a-1)==len(s)-b-1:
return '答案正确'
return '答案错误'
#输入
n = eval(input())
# s = []
out = []
for i in range(n):
a = input()
# s.append(a)
if judge(a)=='答案正确':
out.append('YES')
else:
out.append('NO')
for i in out:
print(i)