easy Version比较简单
不考虑吃碰杠,只考虑3个和2个相同的情况,实际上就只需要统计一下相同有3张的牌的种数和有2张牌的种数
即:有4种3张相同的牌(如分别有3张1W,3张2W,3张3W,3张4W,共4种)且有一个对子
或是有7个对子
用map对每种牌出现的次数进行计数,读入数据时就进行筛选是否满足缺一门的要求
mp[i]表示i代表的牌出现的次数
最后看map中的value是不是4个3和1个2
或者是有7个2

#include<bits/stdc++.h>
using namespace std;
int getId(char num, char type) {
    if(type == 'W')
        return num - '0';
    if(type == 'T')
        return num - '0' + 10;
    else
        return num - '0' + 20;
}
bool judge(int id, char type) {
    if(1 <= id && id <= 9 && type == 'W')
        return true;
    if(11 <= id && id <= 19 && type == 'T')
        return true;
    if(21 <= id && id <= 29 && type == 'S')
        return true;
    return false;
}
int main() {
    int n;
    while(cin>>n) {
        char que; cin>>que;
        while(n--) {
            map<int, int> mp;
            bool mark = true;
            char pai[50]; cin>>pai;
            for(int i = 0; i < 14; ++i) {
                int id = getId(pai[i*2], pai[i*2 + 1]);
                if(judge(id, que)) {
                    mark = false;
                    break;
                }
                mp[id]++;
            }
            int cnt2 = 0, cnt3 = 0;
            for(auto it = mp.begin(); it != mp.end(); ++it)
                if(it->second == 2) ++cnt2;
                else if(it->second == 3) ++cnt3;
            if(!(cnt2 == 7 || (cnt2 == 1 && cnt3 == 4)))
                mark = false;
            printf(mark ? "Yes\n" : "No\n");
        }
    }
    return 0;
}