【PAT】B1003 我要通过(20 分)

#include <string.h>
#include<stdio.h>
#include <map>
using namespace std;
int main() {
    int n, p = 0, t = 0;
    char s[120];
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%s",s);
        map<char, int> m;
        for(int j = 0; j < strlen(s); j++) {
            m[s[j]]++;
            if (s[j] == 'P') p = j;
            if (s[j] == 'T') t = j;
        }
        if(m['P'] == 1 && m['A'] != 0 && m['T'] == 1 && m.size() == 3 && p * (t-p-1) == strlen(s)-t-1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/hebust/p/9498159.html