m0_67812945 2022-07-12 16:48 采纳率: 0%
浏览 16

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;
}**

  • 写回答

1条回答 默认 最新

报告相同问题?

问题事件

  • 创建了问题 7月12日

悬赏问题

  • ¥15 汇编语言没有主程序吗?
  • ¥15 这个函数为什么会爆内存
  • ¥15 无法装系统,grub成了顽固拦路虎
  • ¥15 springboot aop 应用启动异常
  • ¥15 matlab有关债券凸性久期的代码
  • ¥15 lvgl v8.2定时器提前到来
  • ¥15 qtcp 发送数据时偶尔会遇到发送数据失败?用的MSVC编译器(标签-qt|关键词-tcp)
  • ¥15 cam_lidar_calibration报错
  • ¥15 拓扑学,凸集,紧集。。
  • ¥15 如何扩大AIS数据容量