问题测试点一过不了
问题相关代码,请勿粘贴截图
**# include <iostream>
# include <string>
using namespace std;
int main()
{
int n, i, b = 1, count = 0, m, ns=0, m_count = 0, counts = 0;
int temp, temps;
cin >> n;
for (i = 0;i < n;i++)
{
string a;
cin >> a;
if (a == "PAT")
{
cout << "YES" << endl;
continue;
}
m = a.length();
char flag = 'P';
char flags = 'T';
temp = a.find_first_of(flag);
temps = a.find_first_of(flags);
while (ns < temp)
{
if (a[ns] == 'A')
{
count++;
}
else
{
b = 0;
break;
}
ns++;
}
if (a[ns] == 'P')
{
ns++;
}
while (ns > temp && ns < temps)
{
if (a[ns] == 'A')
{
m_count++;
}
else
{
b = 0;
break;
}
ns++;
}
if (a[ns] == 'T')
{
ns++;
}
while (ns > temps)
{
if (a[ns] == 'A')
{
counts++;
}
else
{
break;
}
ns++;
}
if (m_count == 1 && count == counts)
{
cout << "YES" << endl;
continue;
}
if (m_count * count == counts && b != 0&&m_count>=1)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
count = 0, counts = 0, m_count = 0, ns = 0;
}
return 0;
}**