PTA 乙级 1003 我要通过! (20分)

 1 num = eval(input())
 2 an = []
 3 for i in range(0,num):
 4     str = input()
 5     P = str.count('P')
 6     T = str.count('T')
 7     A = str.count('A')
 8     sum = P+T+A
 9     #print(sum)
10     #print(len(str))
11     if P!=1 or T!=1 or sum!=len(str) or A == 0:
12         an.append('NO')
13         continue
14     ap = str.find('P')
15     t = str.find('T')
16     pt = t - ap - 1
17     ta = len(str) - t - 1
18     if(ap*pt == ta and ap >= 0):
19         an.append('YES') 
20     else:
21         an.append('NO')
22 
23 for i in range(0,num):
24     print(an[i])

猜你喜欢

转载自www.cnblogs.com/SCP-514/p/13190950.html