QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290497 | #4859. Poker Game: Construction | ucup-team1134# | AC ✓ | 838ms | 6160kb | C++20 | 26.0kb | 2023-12-25 04:34:07 | 2023-12-25 23:53:08 |
Judging History
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);
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 591ms
memory: 6124kb
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: 583ms
memory: 5836kb
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: 590ms
memory: 5868kb
input:
1 3C 3D 3H 5S
output:
YES 3S 2C 4C 7C 8C 9C YES 2C 2D 4C 4D 6C 6D YES 3S 5C 2C 2D 5D 5H
result:
ok 1 test cases (1 test case)
Test #4:
score: 0
Accepted
time: 587ms
memory: 5872kb
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 #5:
score: 0
Accepted
time: 838ms
memory: 5912kb
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:
ok 100000 test cases (100000 test cases)
Test #6:
score: 0
Accepted
time: 817ms
memory: 5840kb
input:
100000 6D 7D 8C JH 2C 4S 3D 2D 8C AD 7H 5S QC JC JH 7H TC TH 9D 5D 7S 3C TC 7D JD 5C 4C 6D 4S 5H 7D 6C AC TH 7D 4D QH 3D TS KC AD 8D 5H 3S 9D 6D 6S 2C JH KS 7C 3H QD 7C 7S KD 8H 9D 3C KD 7H 9S KD TS 5D KH 3C AC 4S 3D 4C 3C 9C 2H 8C JH 8H 9C KS 5S QC 4S 9H TH TD KD JC 8D AS KH KS 2H 7D 6D AD 6S 7H 6C...
output:
YES 6C 6H 6S 7C 7H 7S YES 8H 8S 8D JC JS JD NO YES 4C 4H 4D 5C 7C 8C YES 3C 3H 3S 5C 7C 2H YES 4C 3C 2H 2S 3H 3S YES 8D 8H 8S AC AH AS YES 5C 5D 5H 7C 7D 7S NO YES QD QS QH 2D 3D 4D YES 7D 7S 7C 2D 3D JD YES QD 7D 2D 2S 7S 7C YES TS TD 2C 3C 4C 7C YES 5C 5H 5S 9C 9H 9S NO YES 3D 3H 3S 2C 4C 5C YES T...
result:
ok 100000 test cases (100000 test cases)
Test #7:
score: 0
Accepted
time: 816ms
memory: 5920kb
input:
100000 5S 6H 6D KH AS 3D KS 3S 7S 4S 7D JD 4D 6D 7D AD 2C JH 6C QD 7H TC JD 3C TC 2C AH JH 3C 9S 5S 9H JC 6H QS 3H 6D 7C 2D 4D 9H 8C QC KS 7H 9S TH JS JS AS 8H QH 8D 5S 7S 3S 2D QD AC 9H 3H 6S 8H JC 3H 8C 4H AS QC TH 9S 6S 3S 9D 7C TC QS JC 6S 9S 4C 9S 5S 6D 3H AH 4D 3D 7H 2C QH 7C 3C QS QD KH 5C QH...
output:
YES 5C 5D 5H 2C 3C 7C YES KC KD KS 2C 3C 6C YES 5C KC 2C 2D 2H 2S YES AC AD AH 2C 4C 6C YES KC KD KH 2C 4C 3C YES AC KC 2C 2D KD KH YES 4C 4H 4D 2C 3C 5C YES JC JH JS 2C 3C 7C YES 4C JC 2C 2H 2D 2S YES 4C 4H 4S 6C 6H 6S YES 7C 7H 7S AC AH AS NO YES 2D 2H 2S JC JD JS YES 6D 6H 6S QC QH QS YES 2D JC 6...
result:
ok 100000 test cases (100000 test cases)
Test #8:
score: 0
Accepted
time: 823ms
memory: 6160kb
input:
100000 QS 2C 8D 3H AD JD 5H 9H 5C JS 4S 3C 9D 9S TH QC 6C 6H QH 4S JH JD 7H 6C KC 9D 4C 5C 3H QC 6H 8H 7S 4S 3S 8C 6C 4D AD 9H 8H 3S JS KC 3C AS 9S 2C 8D 7D 8S KC 4S JD TH 7D 3D 9S AD AC 9D 2D 2S KH 6D AC 7H 2D 4D AC 5D JC JH JD 2C 6D 8S 6D 9S 5S JD 9C 6C 7S TC 6H TH 9H JD 8D 8H KH 5C 9C AH 9D 2S TH...
output:
YES 2D 2H 2S QC QD QH YES 3C 3D 3S 8C 8H 8S YES 2D QC 3C 8C 3D 3S YES AC AS AH JC JS JH YES 5C 5S 5D 9C 9S 9D NO YES 5D 5H 5S JC JD JH YES 3D 3H 3S 4C 4D 4H NO YES 9C 9H 2C 3C 4C 5C YES QD QH QS TC TD TS NO YES 6D 6S 2C 3C 7C 8C YES 4C 4D 4H QC QD QS NO YES JC JS 2C 3C 4C 8C YES 6D 6H 6S 7C 7D 7S NO...
result:
ok 100000 test cases (100000 test cases)
Test #9:
score: 0
Accepted
time: 828ms
memory: 5956kb
input:
100000 JS TS 6S AH 9H 2D 9D 2C 8S TH KC 9H AD 7H AS 2S 6D TC TS 9D 2S 3C JH 2D 7D QH 2D KC JD 8C 4D TS 7C 2H JC 6C 2S 8C AH 5C JS 2D AH QD 6D 6H 9D TH KD 2H 2S AC 2H 3D AH 9H 2H KC TS JC 2H 5H 8S KD 4H 6C 5S QS 3D AC 5S JC 7S 9C KS 5S 9C AD KC 4H 5H KH TD KD 8C 4D 3S 8S 5D JC JS KS 8H AD 8D 2H AS QD...
output:
YES JC JD JH TC TD TH YES 6C 6D 6H AC AD AS NO YES 3C 4C 5C 7C 3D 3H NO YES 3C 3D 4C 4D 5C 5D YES 8C 8D 8H TC TD TS YES 9C 9D 9S KD KH KS YES 8C TC 9C KD 2C 2D YES 7C 7D 7S 3C 4C 6C YES 2C 2D 2H 3C 4C AC YES 7C 2C 2D 2H 3C 3D YES 6C 6H 6S 2C 3C 4C YES 9C 9H 9S 2C 3C TD YES 6C 9C 2C 2D 2H 2S YES 3D 3...
result:
ok 100000 test cases (100000 test cases)
Test #10:
score: 0
Accepted
time: 818ms
memory: 5884kb
input:
100000 TH 9C 3H KH QD 5C AS 7D 6D 4C 5S 7H 2D 6H 9C 4C JD AC 7D JC TC 3S QH 2D JC 5H 9D 7S 6S TC 7S KC 4S TS 7S QS TD KS 7D 8H KS 2D 5H 7C 9C KH 2S 9D JD 5H 9C QH 7D QC 6H KC 6S 7D KS 6C TC KD 2C 4D 3S 5S AD 6S KH 7D KS 5H QC QH 8C 3S KH AC 8D TS QD TH 9C 8C KS 8H 9C QC 6D 8H 9D TH 9C 5S 6C 6S KH 6S...
output:
YES 9D 9S 9H TC TD TS YES 3C 3D 3S KC KD KS NO YES 5D 5H 5S QC QH QS YES 7C 7H 7S AC AD AH YES 5D QC 7C AC 2C 2D YES 4D 4H 4S 6C 6H 6S YES 5C 5D 5H 7C 7D 7S YES 4D 6C 5C 7C 2C 2D YES 2H 2S 2C 6D 6S 6C YES 4D 4H 4S 9D 9H 9S YES 2H 6D 4D 9D 3D 3H YES AD AH AS 2C 3C 4C YES 7C 7H 7S 2C 3C JH YES AD 7C 2...
result:
ok 100000 test cases (100000 test cases)