PAT 1003. 我要通过!(20) 有个测试点过不了 求解答

问题测试点一过不了

img

img

img

问题相关代码,请勿粘贴截图
**# 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;
}**

供参考:https://blog.csdn.net/weixin_45947840/article/details/105900982?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0.essearch_pc_relevant&spm=1001.2101.3001.4242