QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290497#4859. Poker Game: Constructionucup-team1134#AC ✓821ms6068kbC++2026.0kb2023-12-25 04:34:072023-12-25 04:34:07

Judging History

你现在查看的是测评时间为 2023-12-25 04:34:07 的历史记录

  • [2023-12-25 23:53:08]
  • 管理员手动重测该提交记录
  • 测评结果:AC
  • 用时:838ms
  • 内存:6160kb
  • [2023-12-25 04:34:07]
  • 评测
  • 测评结果:0
  • 用时:821ms
  • 内存:6068kb
  • [2023-12-25 04:34:07]
  • 提交

answer

// https://codeforces.com/gym/103914/submission/171747570



// https://onlinejudge.u-aizu.ac.jp/solutions/problem/2535/review/4576753/syl659/C++11
// https://judge.yosupo.jp/submission/21682
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=15;
const int INF=1<<30;
//const ll INF=1LL<<60;

string suits = "CDHS";
string ranks = "23456789TJQKA";
int str2int(string s){
    int res = 0;
    for(int i=0; i<4; i++){
        if(s[1]==suits[i]) res += i*13;
    }
    for(int i=0; i<13; i++){
        if(s[0]==ranks[i]) res += i;
    }
    return res;
}

int getint(string &s){
    if(s[0]=='T') return 8;
    if(s[0]=='J') return 9;
    if(s[0]=='Q') return 10;
    if(s[0]=='K') return 11;
    if(s[0]=='A') return 12;
    return (int)(s[0]-'2');
}

vector<int> highest_hand_without_flush(vector<int> a){
    vector<int> c(13,false);
    vector<int> ranks(13, 0);
    for(int i=0; i<(int)a.size(); i++){
        int rank = a[i];
        c[rank] = true;
        ranks[rank]++;
    }
    vector<vector<int>> n2r(5);
    for(int i=12; i>=0; i--){
        n2r[ranks[i]].push_back(i);
    }
    // フォーカード
    if(!n2r[4].empty()){
        for(int i=12; i>=0; i--){
            if(ranks[i]==0 or i==n2r[4][0]) continue;
            return {7, n2r[4][0], i};
        }
    }
    // フルハウス
    if(!n2r[3].empty() and (n2r[3].size() +n2r[2].size())>=2u){
        for(int i=12; i>=0; i--){
            if(i==n2r[3][0] or ranks[i]<2) continue;
            return {6, n2r[3][0], i};
        }
    }
    // ストレート
    for(int i=12; i>=3; i--){
        bool ok = true;
        for(int j=0; j<5; j++){
            int rank = (i-j>=0)? i-j: 12;
            if(ranks[rank] == 0){
                ok = false;
                break;
            }
        }
        if(ok) return {4, i};
    }
    // スリーカード
    if(!n2r[3].empty()){
        return {3, n2r[3][0], n2r[1][0], n2r[1][1]};
    }
    // ツーペア
    if((int)n2r[2].size() >= 2){
        int rem = (n2r[2].size()>2u)? max(n2r[2][2], n2r[1][0]): n2r[1][0];
        return {2, n2r[2][0], n2r[2][1], rem};
    }
    // ワンペア
    if((int)n2r[2].size() == 1){
        return {1, n2r[2][0], n2r[1][0], n2r[1][1], n2r[1][2]};
    }
    vector<int> res{0};
    res.insert(res.end(), n2r[1].begin(), n2r[1].begin()+5);
    return res;
}

vector<int> highest_hand(vector<string> aa){
    vector<int> a;
    for(auto x:aa){
        a.push_back(str2int(x));
    }
    vector<vector<bool>> c(4, vector<bool>(13, false));
    vector<int> suits(4, 0);
    vector<int> ranks(13, 0);
    for(int i=0; i<(int)a.size(); i++){
        int suit = a[i]/13;
        int rank = a[i]%13;
        c[suit][rank] = true;
        suits[suit]++;
        ranks[rank]++;
    }
    vector<vector<int>> n2r(5);
    for(int i=12; i>=0; i--){
        n2r[ranks[i]].push_back(i);
    }
    
    for(int i=0; i<4; i++){
        for(int j=12; j>=3; j--){
            bool ok = true;
            for(int k=0; k<5; k++){
                int rank = (j-k>=0)? j-k: 12;
                if(!c[i][rank]){
                    ok = false;
                    break;
                }
            }
            if(ok) return {8, j};
        }
    }
    // フォーカード
    if(!n2r[4].empty()){
        for(int i=12; i>=0; i--){
            if(ranks[i]==0 or i==n2r[4][0]) continue;
            return {7, n2r[4][0], i};
        }
    }
    // フルハウス
    if(!n2r[3].empty() and (n2r[3].size() +n2r[2].size())>=2u){
        for(int i=12; i>=0; i--){
            if(i==n2r[3][0] or ranks[i]<2) continue;
            return {6, n2r[3][0], i};
        }
    }
    // フラッシュ
    for(int i=0; i<4; i++){
        if(suits[i] < 5) continue;
        vector<int> res{5};
        for(int j=12; j>=0; j--){
            if(c[i][j]) res.push_back(j);
            if((int)res.size() == 6) return res;
        }
    }
    // ストレート
    for(int i=12; i>=3; i--){
        bool ok = true;
        for(int j=0; j<5; j++){
            int rank = (i-j>=0)? i-j: 12;
            if(ranks[rank] == 0){
                ok = false;
                break;
            }
        }
        if(ok) return {4, i};
    }
    // スリーカード
    if(!n2r[3].empty()){
        return {3, n2r[3][0], n2r[1][0], n2r[1][1]};
    }
    // ツーペア
    if((int)n2r[2].size() >= 2){
        int rem = (n2r[2].size()>2u)? max(n2r[2][2], n2r[1][0]): n2r[1][0];
        return {2, n2r[2][0], n2r[2][1], rem};
    }
    // ワンペア
    if((int)n2r[2].size() == 1){
        return {1, n2r[2][0], n2r[1][0], n2r[1][1], n2r[1][2]};
    }
    vector<int> res{0};
    res.insert(res.end(), n2r[1].begin(), n2r[1].begin()+5);
    return res;
}

vector<string> AA,BB,SS;
bool seen[1<<6][1<<6];
int win[1<<6][1<<6];

int solve(int rem,int alice,int turn){
    if(seen[rem][alice]) return win[rem][alice];
    
    seen[rem][alice]=true;
    
    if(rem==0){
        vector<string> S=AA,T=BB;
        for(int i=0;i<6;i++){
            if(alice&(1<<i)){
                S.push_back(SS[i]);
            }else{
                T.push_back(SS[i]);
            }
        }
        vector<int> ma1,ma2;
        ma1=highest_hand(S);
        ma2=highest_hand(T);
        
        if(ma1>ma2) return win[rem][alice]=1;
        else if(ma1==ma2) return win[rem][alice]=0;
        return win[rem][alice]=-1;
    }else{
        if(turn==0){
            int res=-3;
            for(int i=0;i<6;i++){
                if(!(rem&(1<<i))) continue;
                chmax(res,solve(rem-(1<<i),alice|(1<<i),turn^1));
                if(res==1) break;
            }
            return win[rem][alice]=res;
        }else{
            int res=3;
            for(int i=0;i<6;i++){
                if(!(rem&(1<<i))) continue;
                chmin(res,solve(rem-(1<<i),alice,turn^1));
                if(res==-1) break;
            }
            return win[rem][alice]=res;
        }
    }
}

vector<int> AAA,BBB,SSS;
bool seeen[1<<6][1<<6];
int wiin[1<<6][1<<6];

int solve_without_flush(int rem,int alice,int turn){
    if(seeen[rem][alice]) return wiin[rem][alice];
    
    seeen[rem][alice]=true;
    
    if(rem==0){
        vector<int> S=AAA,T=BBB;
        for(int i=0;i<6;i++){
            if(alice&(1<<i)){
                S.push_back(SSS[i]);
            }else{
                T.push_back(SSS[i]);
            }
        }
        vector<int> ma1,ma2;
        ma1=highest_hand_without_flush(S);
        ma2=highest_hand_without_flush(T);
        
        if(ma1>ma2) return wiin[rem][alice]=1;
        else if(ma1==ma2) return wiin[rem][alice]=0;
        return wiin[rem][alice]=-1;
    }else{
        if(turn==0){
            int res=-3;
            for(int i=0;i<6;i++){
                if(!(rem&(1<<i))) continue;
                chmax(res,solve_without_flush(rem-(1<<i),alice|(1<<i),turn^1));
                if(res==1) break;
            }
            return wiin[rem][alice]=res;
        }else{
            int res=3;
            for(int i=0;i<6;i++){
                if(!(rem&(1<<i))) continue;
                chmin(res,solve_without_flush(rem-(1<<i),alice,turn^1));
                if(res==-1) break;
            }
            return wiin[rem][alice]=res;
        }
    }
}

string get(int ran,int sui){
    string res;
    res+=ranks[ran];
    res+=suits[sui];
    return res;
}

bool drawabac[14][14][14][14][14];
pair<int,int> drawuse[14][14][14];

int Duse[14][14][14][14];

int henkan(char c){
    if(c=='C') return 0;
    if(c=='D') return 1;
    if(c=='H') return 2;
    if(c=='S') return 3;
    return -1;
}

int chan(string S){
    return getint(S)*4+henkan(S[1]);
}

int chancn[55];

vector<int> usenumber[1<<13][7];

vector<int> st[14][14];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<string> mu;
    
    auto output=[&](vector<string> &S){
        if(si(S)==0){
            cout<<"NO\n";
        }else{
            //assert(si(S)==6);
            cout<<"YES";
            for(auto a:S) cout<<" "<<a;
            cout<<"\n";
        }
    };
    
    auto make_without_flush=[&](vector<string> &A,vector<string> &B,vector<int> &use){
        vector<string> res(si(use));
        vector<int> cc(4);
        if(A[0][1]==A[1][1]) cc[henkan(A[0][1])]=1;
        if(B[0][1]==B[1][1]) cc[henkan(B[0][1])]=1;
        
        vector<int> jun;
        for(int i=0;i<4;i++){
            if(!cc[i]) jun.push_back(i);
        }
        for(int i=0;i<4;i++){
            if(cc[i]) jun.push_back(i);
        }
        
        chancn[chan(A[0])]++;
        chancn[chan(A[1])]++;
        chancn[chan(B[0])]++;
        chancn[chan(B[1])]++;
        for(int i=0;i<si(use);i++){
            for(int a:jun){
                if(chancn[use[i]*4+a]==0){
                    string A=get(use[i],a);
                    res[i]=(A);
                    chancn[use[i]*4+a]++;
                    break;
                }
            }
        }
        for(int i=0;i<si(res);i++){
            chancn[chan(res[i])]=0;
        }
        chancn[chan(A[0])]=0;
        chancn[chan(A[1])]=0;
        chancn[chan(B[0])]=0;
        chancn[chan(B[1])]=0;
        output(res);
    };
    
    for(int a=0;a<13;a++){
        for(int b=0;b<13;b++){
            for(int c=0;c<13;c++){
                for(int d=c;d<13;d++){
                    for(int e=d;e<13;e++){
                        if(si(st[a][b])) continue;
                        vector<int> Y={a,b,c,d,e};
                        sort(all(Y));
                        bool f=true;
                        for(int i=0;i<4;i++) f&=(Y[i]+1==Y[i+1]);
                        if(Y==vector<int>{0,1,2,3,12}) f=true;
                        if(f){
                            st[a][b]={c,d,e};
                        }
                    }
                }
            }
        }
    }
    
    for(int bit=0;bit<(1<<13);bit++){
        if(__builtin_popcount(bit)>4) continue;
        for(int S=0;S<(1<<13);S++){
            if(bit&S) continue;
            if(__builtin_popcount(S)>6) continue;
            if(si(usenumber[bit][__builtin_popcount(S)])) continue;
            int use=bit|S;
            use*=2;
            if(use&(1<<13)) use|=(1<<0);
            //if(use&1) use|=(1<<13);
            bool ok=true;
            for(int i=0;i<=9;i++){
                int cn=0;
                for(int j=0;j<5;j++) if(use&(1<<(i+j))) cn++;
                if(cn==5) ok=false;
            }
            if(ok){
                for(int s=0;s<13;s++){
                    if(S&(1<<s)) usenumber[bit][__builtin_popcount(S)].push_back(s);
                }
            }
        }
        //for(int j=0;j<=6;j++) assert(usenumber[bit][j]!=-1);
    }
    
    vector<int> cn(13);
    for(int a=0;a<13;a++){
        for(int b=0;b<13;b++){
            for(int c=0;c<13;c++){
                drawuse[a][b][c]=mp(-1,-1);
                for(int d=0;d<13;d++){
                    if(drawuse[a][b][c].fi!=-1) break;
                    for(int e=d;e<13;e++){
                        if(drawuse[a][b][c].fi!=-1) break;
                        cn[a]++;
                        cn[b]++;
                        cn[c]++;
                        cn[d]++;
                        cn[e]++;
                        bool ok=true;
                        if(cn[a]>=3) ok=false;
                        if(cn[b]>=3) ok=false;
                        if(cn[c]>=3) ok=false;
                        if(cn[d]>=3) ok=false;
                        if(cn[e]>=3) ok=false;
                        cn[a]--;
                        cn[b]--;
                        cn[c]--;
                        cn[d]--;
                        cn[e]--;
                        
                        if(!ok) continue;
                        
                        AAA.clear();
                        BBB.clear();
                        SSS.clear();
                        memset(seeen,0,sizeof(seeen));
                        memset(wiin,0,sizeof(wiin));
                        AAA.push_back(a);
                        AAA.push_back(b);
                        BBB.push_back(a);
                        BBB.push_back(c);
                        SSS.push_back(b);
                        SSS.push_back(c);
                        SSS.push_back(d);
                        SSS.push_back(d);
                        SSS.push_back(e);
                        SSS.push_back(e);
                        
                        int res=solve_without_flush(63,0,0);
                        if(res==0){
                            drawabac[a][b][c][d][e]=true;
                            drawuse[a][b][c]=mp(d,e);
                        }
                    }
                }
            }
        }
    }
    
    for(int a=0;a<13;a++){
        for(int b=a;b<13;b++){
            for(int c=0;c<13;c++){
                for(int d=c;d<13;d++){
                    Duse[a][b][c][d]=-1;
                    Duse[b][a][c][d]=-1;
                    Duse[a][b][d][c]=-1;
                    Duse[b][a][d][c]=-1;
                    for(int e=0;e<13;e++){
                        if(Duse[a][b][c][d]!=-1) break;
                        cn[a]++;
                        cn[b]++;
                        cn[c]++;
                        cn[d]++;
                        cn[e]++;
                        bool ok=true;
                        if(cn[a]>=3) ok=false;
                        if(cn[b]>=3) ok=false;
                        if(cn[c]>=3) ok=false;
                        if(cn[d]>=3) ok=false;
                        if(cn[e]>=3) ok=false;
                        cn[a]--;
                        cn[b]--;
                        cn[c]--;
                        cn[d]--;
                        cn[e]--;
                        
                        if(!ok) continue;
                        
                        AAA.clear();
                        BBB.clear();
                        SSS.clear();
                        memset(seeen,0,sizeof(seeen));
                        memset(wiin,0,sizeof(wiin));
                        AAA.push_back(a);
                        AAA.push_back(b);
                        BBB.push_back(c);
                        BBB.push_back(d);
                        SSS.push_back(a);
                        SSS.push_back(b);
                        SSS.push_back(c);
                        SSS.push_back(d);
                        SSS.push_back(e);
                        SSS.push_back(e);
                        
                        int res=solve_without_flush(63,0,0);
                        if(res==0){
                            Duse[a][b][c][d]=e;
                            Duse[b][a][c][d]=e;
                            Duse[a][b][d][c]=e;
                            Duse[b][a][d][c]=e;
                        }
                    }
                }
            }
        }
    }
    
    int Q;cin>>Q;
    while(Q--){
        vector<string> A(2),B(2);
        for(int i=0;i<2;i++) cin>>A[i];
        for(int i=0;i<2;i++) cin>>B[i];
        
        sort(all(A));
        sort(all(B));
        map<char,int> cc;
        for(int i=0;i<2;i++) cc[A[i][0]]++;
        for(int i=0;i<2;i++) cc[B[i][0]]++;
        
        if(si(cc)==4){
            vector<int> res1,res2;
            for(int i=0;i<3;i++) res1.push_back(getint(A[0]));
            for(int i=0;i<3;i++) res1.push_back(getint(A[1]));
            make_without_flush(A,B,res1);
            
            for(int i=0;i<3;i++) res2.push_back(getint(B[0]));
            for(int i=0;i<3;i++) res2.push_back(getint(B[1]));
            make_without_flush(A,B,res2);
            
            if(Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])]==-1){
                output(mu);
            }else{
                int x=Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])];
                vector<int> res={getint(A[0]),getint(A[1]),getint(B[0]),getint(B[1]),x,x};
                make_without_flush(A,B,res);
            }
        }
        if(si(cc)==3){
            if(A[0][0]==A[1][0]){
                vector<int> res1,res2;
                for(int i=0;i<2;i++) res1.push_back(getint(A[0]));
                int use=0;
                use|=1<<(getint(A[0]));
                use|=1<<(getint(B[0]));
                use|=1<<(getint(B[1]));
                for(int x:usenumber[use][4]) res1.push_back(x);
                make_without_flush(A,B,res1);
                
                for(int i=0;i<3;i++) res2.push_back(getint(B[0]));
                for(int i=0;i<3;i++) res2.push_back(getint(B[1]));
                make_without_flush(A,B,res2);
                
                if(Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])]==-1){
                    output(mu);
                }else{
                    int x=Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])];
                    vector<int> res={getint(A[0]),getint(A[1]),getint(B[0]),getint(B[1]),x,x};
                    make_without_flush(A,B,res);
                }
            }else if(B[0][0]==B[1][0]){
                vector<int> res1,res2;
                for(int i=0;i<3;i++) res1.push_back(getint(A[0]));
                for(int i=0;i<3;i++) res1.push_back(getint(A[1]));
                make_without_flush(A,B,res1);
                
                for(int i=0;i<2;i++) res2.push_back(getint(B[0]));
                int use=0;
                use|=1<<(getint(B[0]));
                use|=1<<(getint(A[0]));
                use|=1<<(getint(A[1]));
                for(int x:usenumber[use][4]) res2.push_back(x);
                make_without_flush(A,B,res2);
                
                if(Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])]==-1){
                    output(mu);
                }else{
                    int x=Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])];
                    vector<int> res={getint(A[0]),getint(A[1]),getint(B[0]),getint(B[1]),x,x};
                    make_without_flush(A,B,res);
                }
            }else{
                int a,b,c;
                for(int i=0;i<2;i++){
                    if(cc[A[i][0]]==2) a=getint(A[i]);
                    else b=getint(A[i]);
                }
                for(int i=0;i<2;i++){
                    if(cc[B[i][0]]==2) a=getint(B[i]);
                    else c=getint(B[i]);
                }
                vector<int> res1,res2;
                for(int i=0;i<3;i++) res1.push_back(b);
                for(int x:usenumber[(1<<a)|(1<<b)|(1<<c)][3]) res1.push_back(x);
                make_without_flush(A,B,res1);
                
                for(int i=0;i<3;i++) res2.push_back(c);
                int use=0;
                use|=(1<<a);
                use|=(1<<c);
                for(int x:usenumber[(1<<a)|(1<<b)|(1<<c)][2]) res2.push_back(x);
                res2.push_back(a);
                make_without_flush(A,B,res2);
                
                if(drawuse[a][b][c].fi==-1){
                    output(mu);
                }else{
                    int x=drawuse[a][b][c].fi,y=drawuse[a][b][c].se;
                    vector<int> res3={b,c,x,x,y,y};
                    make_without_flush(A,B,res3);
                }
            }
        }
        if(si(cc)==2){
            if(A[0][0]==A[1][0]){
                if(B[0][0]==B[1][0]){
                    vector<int> res1,res2;
                    for(int i=0;i<2;i++) res1.push_back(getint(A[0]));
                    for(int x:usenumber[(1<<getint(A[0]))|(1<<getint(B[0]))][4]) res1.push_back(x);
                    make_without_flush(A,B,res1);
                    
                    for(int i=0;i<2;i++) res2.push_back(getint(B[0]));
                    for(int x:usenumber[(1<<getint(A[0]))|(1<<getint(B[0]))][4]) res2.push_back(x);
                    make_without_flush(A,B,res2);
                    
                    if(Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])]==-1){
                        output(mu);
                    }else{
                        int x=Duse[getint(A[0])][getint(A[1])][getint(B[0])][getint(B[1])];
                        vector<int> res={getint(A[0]),getint(A[1]),getint(B[0]),getint(B[1]),x,x};
                        make_without_flush(A,B,res);
                    }
                }else{
                    int a,b;
                    a=getint(A[0]);
                    b=getint(B[0])^getint(B[1])^a;
                    vector<int> res1,res2;
                    
                    res1.push_back(a);
                    for(int x:usenumber[(1<<a)|(1<<b)][5]) res1.push_back(x);
                    make_without_flush(A,B,res1);
                    
                    // bob kaku
                    if(B[0][1]==B[1][1]){
                        vector<int> res;
                        for(int x:usenumber[(1<<a)|(1<<b)][6]) res.push_back(x);
                        vector<string> Z;
                        for(int i=0;i<6;i++){
                            string aa;
                            aa+=ranks[res[i]];
                            aa+=B[0][1];
                            Z.push_back(aa);
                        }
                        output(Z);
                    }else if(si(st[a][b])){
                        vector<int> res;
                        for(int x:st[a][b]){
                            res.push_back(x);
                            res.push_back(x);
                        }
                        make_without_flush(A,B,res);
                    }else{
                        int c=-1;
                        for(int k=12;k>=0;k--){
                            if(k!=a&&k!=b&&a<k){
                                c=k;
                                break;
                            }
                        }
                        if(c!=-1){
                            vector<int> res={b,b,b,c,c,c};
                            make_without_flush(A,B,res);
                        }else{
                            if(a==11&&b==12){
                                vector<int> res={b,b};
                                for(int x:usenumber[(1<<a)|(1<<b)][4]) res.push_back(x);
                                make_without_flush(A,B,res);
                            }else{
                                assert(a==12);
                                output(mu);
                            }
                        }
                    }
                    
                    if(drawuse[a][a][b].fi==-1){
                        output(mu);
                    }else{
                        int x=drawuse[a][a][b].fi,y=drawuse[a][a][b].se;
                        vector<int> res3={a,b,x,x,y,y};
                        make_without_flush(A,B,res3);
                    }
                }
            }else{
                if(B[0][0]==B[1][0]){
                    int a,b;
                    a=getint(B[0]);
                    b=getint(A[0])^getint(A[1])^a;
                    
                    vector<int> res1,res2,res3;
                    for(int i=0;i<3;i++) res1.push_back(b);
                    for(int x:usenumber[(1<<a)|(1<<b)][3]) res1.push_back(x);
                    make_without_flush(A,B,res1);
                    
                    for(int x:usenumber[(1<<a)|(1<<b)][3]) res2.push_back(x);
                    res2.push_back(res2[0]);
                    res2.push_back(res2[0]);
                    res2.push_back(res2[0]);
                    make_without_flush(A,B,res2);
                    
                    if(drawuse[a][b][a].fi==-1){
                        output(mu);
                    }else{
                        int x=drawuse[a][b][a].fi,y=drawuse[a][b][a].se;
                        vector<int> res3={b,a,x,x,y,y};
                        make_without_flush(A,B,res3);
                    }
                }else{
                    int a=getint(A[0]),b=getint(A[1]);
                    vector<int> res1,res2,res3;
                    
                    for(int x:usenumber[(1<<a)|(1<<b)][4]) res1.push_back(x);
                    res1.push_back(res1[0]);
                    res1.push_back(res1[0]);
                    make_without_flush(A,B,res1);
                    
                    if(B[0][1]==B[1][1]){
                        vector<int> res;
                        for(int x:usenumber[(1<<a)|(1<<b)][6]) res.push_back(x);
                        vector<string> Z;
                        for(int i=0;i<6;i++){
                            string aa;
                            aa+=ranks[res[i]];
                            aa+=B[0][1];
                            Z.push_back(aa);
                        }
                        output(Z);
                    }else{
                        output(mu);
                    }
                    
                    for(int x:usenumber[(1<<a)|(1<<b)][3]){
                        res3.push_back(x);
                        res3.push_back(x);
                    }
                    make_without_flush(A,B,res3);
                }
            }
        }
        if(si(cc)==1){
            vector<int> res1,res3;
            for(int x:usenumber[(1<<getint(A[0]))][6]) res1.push_back(x);
            make_without_flush(A,B,res1);
            
            output(mu);
            
            for(int x:usenumber[(1<<getint(A[0]))][3]){
                res3.push_back(x);
                res3.push_back(x);
            }
            make_without_flush(A,B,res3);
        }
    }
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 619ms
memory: 5844kb

input:

3
JC 4H
TS 5D
7C 3C
7H TH
2D KH
4D JC

output:

YES 4C 4D 4S JD JH JS
YES 5C 5H 5S TC TD TH
YES 4C JD 5C TC 5H 5S
YES 3D 3S 3H 2D 4D 5D
YES TD TS TC 2D 4D 7D
YES 3D TD 2D 2S 2C 2H
YES 2C 2H 2S KC KD KS
YES 4C 4H 4S JD JH JS
YES 2C KC 4C JD 4H 4S

result:

ok 3 test cases (3 test cases)

Test #2:

score: 0
Accepted
time: 590ms
memory: 5828kb

input:

2
AS AH
AC AD
AS AH
2S 2H

output:

YES 2C 3C 4C 6C 7C 8C
NO
YES 2C 2D 3C 3D 4C 4D
YES AC AD 3C 4C 6C 7C
YES 2C 2D 3C 4C 6C 7C
NO

result:

ok 2 test cases (2 test cases)

Test #3:

score: 0
Accepted
time: 585ms
memory: 6068kb

input:

1
9C KC
JC 5D

output:

YES 9D 9H 9S KD KH KS
YES 5H 5S 5C JD JH JS
YES 9D KD 5H JD 5S 5C

result:

ok 1 test cases (1 test case)

Test #4:

score: -100
Wrong Answer
time: 821ms
memory: 5808kb

input:

100000
6S 7C
KH 3S
5S 2D
AC TS
QD 6H
TC JD
5C AD
4S TH
AD 3S
JC 5S
TH QH
9S JH
AD JC
JS 7H
3S 9S
JC 6S
4D 7S
3S JH
AD JS
7D 4D
7D QS
QH JC
4H JS
7H TS
5D AD
3S 8D
AC TH
5D 3S
9H TD
TS 7D
7D 8C
AD 5H
7C QS
2C TH
QD AS
4S 2H
8D JS
9S 5H
2C TC
2D 5S
TD 2C
AS 2D
6H 6S
AC 2S
2C 8D
4C KS
JD 9D
2D AD
AS QH...

output:

YES 6C 6D 6H 7D 7H 7S
YES 3C 3D 3H KC KD KS
NO
YES 2C 2H 2S 5C 5D 5H
YES AD AH AS TC TD TH
NO
YES 6C 6D 6S QC QH QS
YES JC JH JS TD TH TS
YES 6C QC JC TD TH TS
YES 5D 5H 5S AC AH AS
YES 4C 4D 4H TC TD TS
YES 5D AC 4C TC 4D 4H
YES 3C 3D 3H AC AH AS
YES 5C 5D 5H JD JH JS
YES 3C AC 5C JD 5D 5H
YES QC Q...

result:

FAIL There is bug. (test case 100000)