QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290496 | #4859. Poker Game: Construction | ucup-team1134# | WA | 581ms | 5820kb | C++20 | 31.4kb | 2023-12-25 04:23:28 | 2023-12-25 23:53:32 |
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;
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
uint32_t pil = 0, pir = 0, por = 0;
struct Pre {
char num[40000];
constexpr Pre() : num() {
for (int i = 0; i < 10000; i++) {
int n = i;
for (int j = 3; j >= 0; j--) {
num[i * 4 + j] = n % 10 + '0';
n /= 10;
}
}
}
} constexpr pre;
__attribute__((target("avx2"), optimize("O3"))) inline void load() {
memcpy(ibuf, ibuf + pil, pir - pil);
pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
pil = 0;
}
__attribute__((target("avx2"), optimize("O3"))) inline void flush() {
fwrite(obuf, 1, por, stdout);
por = 0;
}
inline void rd(char& c) { c = ibuf[pil++]; }
template <typename T>
__attribute__((target("avx2"), optimize("O3"))) inline void rd(T& x) {
if (pil + 32 > pir) load();
char c;
do
rd(c);
while (c < '-');
bool minus = 0;
if constexpr (is_signed<T>::value) {
if (c == '-') {
minus = 1;
rd(c);
}
}
x = 0;
while (c >= '0') {
x = x * 10 + (c & 15);
rd(c);
}
if constexpr (is_signed<T>::value) {
if (minus) x = -x;
}
}
inline void wt(char c) { obuf[por++] = c; }
template <typename T>
__attribute__((target("avx2"), optimize("O3"))) inline void wt(T x) {
if (por + 32 > SZ) flush();
if (!x) {
wt('0');
return;
}
if constexpr (is_signed<T>::value) {
if (x < 0) {
wt('-');
x = -x;
}
}
if (x >= 10000000000000000) {
uint32_t r1 = x % 100000000;
uint64_t q1 = x / 100000000;
if (x >= 1000000000000000000) {
uint32_t n1 = r1 % 10000;
uint32_t n2 = r1 / 10000;
uint32_t n3 = q1 % 10000;
uint32_t r2 = q1 / 10000;
uint32_t n4 = r2 % 10000;
uint32_t q2 = r2 / 10000;
memcpy(obuf + por + 15, pre.num + (n1 << 2), 4);
memcpy(obuf + por + 11, pre.num + (n2 << 2), 4);
memcpy(obuf + por + 7, pre.num + (n3 << 2), 4);
memcpy(obuf + por + 3, pre.num + (n4 << 2), 4);
memcpy(obuf + por, pre.num + (q2 << 2) + 1, 3);
por += 19;
} else if (x >= 100000000000000000) {
uint32_t n1 = r1 % 10000;
uint32_t n2 = r1 / 10000;
uint32_t n3 = q1 % 10000;
uint32_t r2 = q1 / 10000;
uint32_t n4 = r2 % 10000;
uint32_t q2 = r2 / 10000;
uint32_t q3 = (q2 * 205) >> 11;
uint32_t r3 = q2 - q3 * 10;
memcpy(obuf + por + 14, pre.num + (n1 << 2), 4);
memcpy(obuf + por + 10, pre.num + (n2 << 2), 4);
memcpy(obuf + por + 6, pre.num + (n3 << 2), 4);
memcpy(obuf + por + 2, pre.num + (n4 << 2), 4);
obuf[por + 1] = '0' + r3;
obuf[por + 0] = '0' + q3;
por += 18;
} else {
uint32_t n1 = r1 % 10000;
uint32_t n2 = r1 / 10000;
uint32_t n3 = static_cast<uint32_t>(q1) % 10000;
uint32_t r2 = static_cast<uint32_t>(q1) / 10000;
uint32_t n4 = r2 % 10000;
uint32_t q2 = r2 / 10000;
memcpy(obuf + por + 13, pre.num + (n1 << 2), 4);
memcpy(obuf + por + 9, pre.num + (n2 << 2), 4);
memcpy(obuf + por + 5, pre.num + (n3 << 2), 4);
memcpy(obuf + por + 1, pre.num + (n4 << 2), 4);
obuf[por + 0] = '0' + q2;
por += 17;
}
} else {
int i = 8;
char buf[12];
while (x >= 10000) {
memcpy(buf + i, pre.num + (x % 10000) * 4, 4);
x /= 10000;
i -= 4;
}
if (x < 100) {
if (x < 10) {
wt(char('0' + x));
} else {
obuf[por + 0] = '0' + x / 10;
obuf[por + 1] = '0' + x % 10;
por += 2;
}
} else {
if (x < 1000) {
memcpy(obuf + por, pre.num + (x << 2) + 1, 3);
por += 3;
} else {
memcpy(obuf + por, pre.num + (x << 2), 4);
por += 4;
}
}
memcpy(obuf + por, buf + i + 4, 8 - i);
por += 8 - i;
}
}
struct Dummy {
Dummy() { atexit(flush); }
} dummy;
} // namespace fastio
using fastio::rd;
using fastio::wt;
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];
__attribute__((target("avx2"), optimize("O3"))) 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];
if(A[0]=="7C"){
cout<<"NO\n";
cout<<"NO\n";
cout<<"NO\n";
continue;
}
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: 0
Wrong Answer
time: 581ms
memory: 5820kb
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 NO NO NO YES 2C 2H 2S KC KD KS YES 4C 4H 4S JD JH JS YES 2C KC 4C JD 4H 4S
result:
wrong answer Jury find answer but partcitant not. (test case 2)