QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#738399 | #7061. Poker Game | icpc_zhzx034# | WA | 1ms | 3828kb | C++14 | 10.1kb | 2024-11-12 18:58:14 | 2024-11-12 18:58:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define fi first
#define se second
#define mk make_pair
#define eb emplace_back
#define rep(i,l,r) for(int i=(l); i<=(r); ++i)
#define rep_(i,l,r) for(int i=(l); i>=(r); --i)
typedef long long lr;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int mod1=998244353,mod2=1e9+7;
constexpr db pi=3.141592653589793,eps=1e-9;
constexpr int inf32=0x3f3f3f3f,Inf32=0xc0c0c0c0;
constexpr lr inf64=0x3f3f3f3f3f3f3f3f,Inf64=0xc0c0c0c0c0c0c0c0;
template<typename T>il T Max(T x,T y) { return (x>y)? x:y; }
template<typename T>il T Min(T x,T y) { return (x<y)? x:y; }
template<typename T>il T gcd(T x,T y) { return (!y)? x:gcd(y,x%y); }
template<typename T>il T Abs(T x) { return (x>0)? x:(-x); }
template<typename T>il T Rnd(T l,T r,mt19937_64 &eng)
{
uniform_int_distribution<T> uid(l,r);
return uid(eng);
}
mt19937_64 eng(chrono::high_resolution_clock::now().time_since_epoch().count());
constexpr int N=524300;
int col[53],num[53],coll[5],numm[14];
vi pub;
struct Player
{
int pot,dq,fold,bet,allin,c[3];
int tp,key;
Player() { pot=100,dq=0; }
};
Player p[6];
il bool Montagu(vi v)
{
int sz=(int)v.size();
rep(i,0,sz-1)
rep(j,i+1,sz-1)
if(num[v[i]]==num[v[j]])
return 1;
return 0;
}
il bool Molony1(vi v)
{
rep(i,1,4)
coll[i]=0;
rep(i,1,13)
numm[i]=0;
for(int i:v)
++coll[col[i]],++numm[num[i]];
rep(i,1,13)
if(numm[i]>=2)
return 1;
if((numm[1]>0)+(numm[13]>0)+(numm[12]>0)+(numm[11]>0)+(numm[10]>0)>=4)
return 1;
rep_(i,13,5)
if((numm[i]>0)+(numm[i-1]>0)+(numm[i-2]>0)+(numm[i-3]>0)+(numm[i-4]>0)>=4)
return 1;
rep(i,1,4)
if(coll[i]>=4)
return 1;
return 0;
}
il bool Molony2(vi v)
{
rep(i,1,4)
coll[i]=0;
for(int i:v)
++coll[col[i]];
rep(i,1,4)
if(coll[i]>=4)
return 0;
return 1;
}
il bool Hickok(vi v)
{
rep(i,1,13)
numm[i]=0;
for(int i:v)
++numm[num[i]];
rep(i,1,13)
if(numm[i]>=2&&num[p[3].c[1]]!=i&&num[p[3].c[2]]!=i)
return 0;
return 1;
}
il bool Packer1(vi v)
{
int mx=0;
for(int i:v)
mx=(num[i]==1||mx==14)? 14:Max(mx,num[i]);
if(num[p[4].c[1]]==1||num[p[4].c[1]]>=mx||num[p[4].c[2]]==1||num[p[4].c[2]]>=mx)
return 1;
return 0;
}
il bool Packer2(vi v)
{
rep(i,1,4)
coll[i]=0;
rep(i,1,13)
numm[i]=0;
for(int i:v)
++coll[col[i]],++numm[num[i]];
rep(i,1,13)
if(numm[i]>=3)
return 1;
if(numm[1]&&numm[13]&&numm[12]&&numm[11]&&numm[10])
return 1;
rep_(i,13,5)
if(numm[i]&&numm[i-1]&&numm[i-2]&&numm[i-3]&&numm[i-4])
return 1;
rep(i,1,4)
if(coll[i]>=5)
return 1;
if(numm[1]==2)
return 1;
rep_(i,13,2)
if(numm[i]==2)
{
int cnt=0;
for(int j:pub)
cnt+=(num[j]==1||num[j]>=i);
if(cnt<=2)
return 1;
else
return 0;
}
return 0;
}
il bool Karas()
{
int cnt=0;
rep(i,1,4)
if(!p[i].dq&&!p[i].fold)
++cnt;
if(cnt==1)
return 1;
else
return 0;
}
il void Call(int pid,int rid,vi v)
{
if(p[pid].allin)
return;
int Pot=p[pid].pot;
v.eb(p[pid].c[1]);
v.eb(p[pid].c[2]);
if(pid==1)
{
if(rid==0)
{
if(Pot<15||col[v[0]]!=col[v[1]])
{
p[pid].fold=1;
return;
}
if(Pot<15)
p[pid].allin=1;
else
p[pid].bet+=5;
return;
}
if(rid==1)
{
p[pid].bet+=5;
return;
}
if(rid==2)
{
if(!Montagu(v))
{
p[pid].fold=1;
return;
}
p[pid].bet+=5;
return;
}
}
if(pid==2)
{
if(rid==0)
{
if(Pot<15&&(num[v[0]]!=1||num[v[1]]!=1))
{
p[pid].fold=1;
return;
}
if(Pot<15)
p[pid].allin=1;
else
p[pid].bet+=5;
return;
}
if(rid==1)
{
if(!Molony1(v))
{
p[pid].fold=1;
return;
}
p[pid].bet+=5;
return;
}
if(rid==2)
{
if(!Molony2(pub))
{
p[pid].fold=1;
return;
}
p[pid].bet+=5;
return;
}
}
if(pid==3)
{
if(rid==0)
{
if(num[v[0]]!=1&&num[v[1]]!=1&&Abs(num[v[0]]-num[v[1]])>=3)
{
p[pid].fold=1;
return;
}
if(Pot<15)
p[pid].allin=1;
else
p[pid].bet+=5;
return;
}
if(rid==1)
{
if(!Hickok(pub))
{
p[pid].fold=1;
return;
}
p[pid].bet+=5;
return;
}
if(rid==2)
{
p[pid].bet+=5;
return;
}
}
if(pid==4)
{
if(rid==0)
{
if(num[v[0]]>=2&&num[v[0]]<=11&&num[v[1]]>=2&&num[v[1]]<=11)
{
p[pid].fold=1;
return;
}
if(Pot<15)
p[pid].allin=1;
else
p[pid].bet+=5;
return;
}
if(rid==1)
{
if(!Packer1(pub))
{
p[pid].fold=1;
return;
}
p[pid].bet+=5;
return;
}
if(rid==2)
{
if(!Packer2(v))
{
p[pid].fold=1;
return;
}
p[pid].bet+=5;
return;
}
}
if(pid==5)
{
if(rid==0)
{
if(!Karas())
{
p[pid].fold=1;
return;
}
if(Pot<15)
p[pid].allin=1;
else
p[pid].bet+=5;
return;
}
if(rid==1)
{
p[pid].bet+=5;
return;
}
if(rid==2)
{
p[pid].bet+=5;
return;
}
}
}
int q,pwin,card[16];
il int Only()
{
int pos=0;
rep(i,1,5)
if(!p[i].dq&&!p[i].fold)
{
if(pos)
return 0;
pos=i;
}
return pos;
}
il void Settle()
{
int tot=0;
rep(i,1,5)
p[i].bet=((p[i].allin)? p[i].pot:p[i].bet),tot+=p[i].bet,p[i].pot-=p[i].bet;
p[pwin].pot+=tot;
rep(i,1,5)
if(!p[i].pot)
p[i].dq=1;
}
namespace Judge
{
int numcnt[14];
vi hand,colcnt[5];
il int Flush()
{
int mx=0;
rep(i,1,4)
if((int)colcnt[i].size()>=5)
mx=(colcnt[i][0]==1||mx==14)? 14:Max(mx,colcnt[i].back());
return mx;
}
il int Straight()
{
if(numcnt[1]&&numcnt[13]&&numcnt[12]&&numcnt[11]&&numcnt[10])
return 14;
rep_(i,13,5)
if(numcnt[i]&&numcnt[i-1]&&numcnt[i-2]&&numcnt[i-3]&&numcnt[i-4])
return i;
return 0;
}
il int Three()
{
if(numcnt[1]>=3)
return 14;
rep_(i,13,2)
if(numcnt[i]>=3)
return i;
return 0;
}
il int Two()
{
if(numcnt[1]>=2)
return 14;
rep_(i,13,2)
if(numcnt[i]>=2)
return i;
return 0;
}
il int One()
{
if(numcnt[1])
return 14;
rep_(i,13,2)
if(numcnt[i])
return i;
return 0;
}
il void Update(int id,int a1,int a2,int a3,int a4,int a5)
{
rep(j,1,4)
colcnt[j].clear();
rep(j,1,13)
numcnt[j]=0;
colcnt[col[a1]].eb(num[a1]),++numcnt[num[a1]];
colcnt[col[a2]].eb(num[a2]),++numcnt[num[a2]];
colcnt[col[a3]].eb(num[a3]),++numcnt[num[a3]];
colcnt[col[a4]].eb(num[a4]),++numcnt[num[a4]];
colcnt[col[a5]].eb(num[a5]),++numcnt[num[a5]];
rep(j,1,4)
sort(colcnt[j].begin(),colcnt[j].end());
int Tp=0,Key=0;
Key=Flush();
if(Key)
{
Tp=5;
if(Tp>p[id].tp||(Tp==p[id].tp&&Key>p[id].key))
p[id].tp=Tp,p[id].key=Key;
return;
}
Key=Straight();
if(Key)
{
Tp=4;
if(Tp>p[id].tp||(Tp==p[id].tp&&Key>p[id].key))
p[id].tp=Tp,p[id].key=Key;
return;
}
Key=Three();
if(Key)
{
Tp=3;
if(Tp>p[id].tp||(Tp==p[id].tp&&Key>p[id].key))
p[id].tp=Tp,p[id].key=Key;
return;
}
Key=Two();
if(Key)
{
Tp=2;
if(Tp>p[id].tp||(Tp==p[id].tp&&Key>p[id].key))
p[id].tp=Tp,p[id].key=Key;
return;
}
Key=One();
if(Key)
{
Tp=1;
if(Tp>p[id].tp||(Tp==p[id].tp&&Key>p[id].key))
p[id].tp=Tp,p[id].key=Key;
return;
}
}
void Main()
{
rep(i,1,5)
if(!p[i].dq&&!p[i].fold)
{
p[i].tp=0,p[i].key=0;
hand=pub;
hand.eb(p[i].c[1]);
hand.eb(p[i].c[2]);
Update(i,hand[0],hand[1],hand[2],hand[3],hand[4]);
Update(i,hand[0],hand[1],hand[2],hand[3],hand[5]);
Update(i,hand[0],hand[1],hand[2],hand[3],hand[6]);
Update(i,hand[0],hand[1],hand[2],hand[4],hand[5]);
Update(i,hand[0],hand[1],hand[2],hand[4],hand[6]);
Update(i,hand[0],hand[1],hand[2],hand[5],hand[6]);
Update(i,hand[0],hand[1],hand[3],hand[4],hand[5]);
Update(i,hand[0],hand[1],hand[3],hand[4],hand[6]);
Update(i,hand[0],hand[1],hand[3],hand[5],hand[6]);
Update(i,hand[0],hand[1],hand[4],hand[5],hand[6]);
Update(i,hand[0],hand[2],hand[3],hand[4],hand[5]);
Update(i,hand[0],hand[2],hand[3],hand[4],hand[6]);
Update(i,hand[0],hand[2],hand[3],hand[5],hand[6]);
Update(i,hand[0],hand[2],hand[4],hand[5],hand[6]);
Update(i,hand[0],hand[3],hand[4],hand[5],hand[6]);
Update(i,hand[1],hand[2],hand[3],hand[4],hand[5]);
Update(i,hand[1],hand[2],hand[3],hand[4],hand[6]);
Update(i,hand[1],hand[2],hand[3],hand[5],hand[6]);
Update(i,hand[1],hand[2],hand[4],hand[5],hand[6]);
Update(i,hand[1],hand[3],hand[4],hand[5],hand[6]);
Update(i,hand[2],hand[3],hand[4],hand[5],hand[6]);
}
rep(i,1,5)
if(!p[i].dq&&!p[i].fold)
if(!pwin||(p[i].tp>p[pwin].tp)||(p[i].tp==p[pwin].tp&&p[i].key>=p[pwin].key))
pwin=i;
}
}
il void Solve()
{
rep(i,1,52)
col[i]=(i+12)/13,num[i]=(i+12)%13+1;
cin>>q;
while(q--)
{
rep(i,1,15)
cin>>card[i];
int ccnt=0;
rep(i,1,5)
if(!p[i].dq)
p[i].fold=0,p[i].bet=0,p[i].allin=0,p[i].c[1]=card[++ccnt],p[i].c[2]=card[++ccnt];
pub.clear(),pwin=0;
bool flag=0;
rep(i,1,5)
{
pwin=Only();
if(pwin)
{
flag=1,Settle();
break;
}
if(!p[i].dq&&!p[i].fold)
Call(i,0,pub);
}
if(flag)
continue;
rep(i,1,3)
pub.eb(card[++ccnt]);
rep(i,1,5)
{
pwin=Only();
if(pwin)
{
flag=1,Settle();
break;
}
if(!p[i].dq&&!p[i].fold)
Call(i,1,pub);
}
if(flag)
continue;
rep(i,1,2)
pub.eb(card[++ccnt]);
rep(i,1,5)
{
pwin=Only();
if(pwin)
{
flag=1,Settle();
break;
}
if(!p[i].dq&&!p[i].fold)
Call(i,2,pub);
}
if(flag)
continue;
pwin=Only();
if(!pwin)
Judge::Main();
Settle();
}
rep(i,1,5)
cout<<p[i].pot<<'\n';
}
int main()
{
#ifdef LOCAL
string fpre="test",isuf="in",osuf="out";
assert(freopen((fpre+"."+isuf).c_str(),"r",stdin));
assert(freopen((fpre+"."+osuf).c_str(),"w",stdout));
#endif
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
while(T--)
Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
2 1 2 8 10 3 11 15 12 14 27 42 43 45 48 13 14 2 8 10 3 11 5 23 1 27 42 43 13 45 48
output:
90 90 100 115 105
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
5 9 5 19 35 30 42 18 8 21 51 16 26 32 29 49 17 50 13 7 37 21 25 31 28 18 30 27 24 16 15 31 38 52 46 1 29 41 12 39 24 10 45 13 22 42 8 10 33 18 39 49 29 43 51 2 35 19 27 41 12 48 13 33 39 30 47 32 24 12 9 42 1 18 41 51
output:
65 115 115 100 105
result:
ok 5 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
5 51 31 17 50 24 15 25 20 22 16 44 6 19 39 28 34 1 21 10 31 15 35 8 27 51 32 23 48 24 29 39 18 27 14 31 2 35 51 44 21 24 6 43 16 19 9 44 4 19 35 47 15 51 25 20 40 8 21 6 7 49 35 11 12 44 29 22 9 16 13 4 17 32 25 7
output:
100 125 115 75 85
result:
ok 5 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
5 16 41 30 6 5 39 22 1 29 42 32 49 40 27 21 39 14 32 48 6 37 23 35 13 52 43 2 24 38 45 49 42 38 18 47 52 30 15 16 1 26 31 28 6 40 47 31 22 45 49 46 36 17 35 48 38 33 13 16 20 41 17 9 34 25 21 8 18 22 24 4 20 26 15 42
output:
90 80 100 115 115
result:
ok 5 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
5 26 38 46 4 52 15 51 7 1 30 5 3 33 47 34 22 7 15 9 5 29 32 23 30 25 33 2 1 50 4 22 44 31 33 32 39 26 5 21 15 48 2 52 37 13 21 50 12 7 43 26 32 28 42 30 20 9 35 47 8 38 12 4 33 10 25 50 37 46 36 6 40 29 48 5
output:
100 65 100 120 115
result:
ok 5 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
5 32 51 43 23 30 17 36 37 48 22 46 41 20 1 42 49 29 40 4 19 46 13 39 8 12 47 38 16 32 34 37 34 45 36 10 26 33 21 46 35 39 13 41 27 19 51 15 42 35 27 52 18 1 44 37 26 39 33 32 8 31 50 52 24 37 17 26 2 20 13 1 38 9 49 51
output:
85 105 110 100 100
result:
ok 5 lines
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3696kb
input:
50 13 27 25 40 35 8 4 48 24 21 23 41 28 34 46 17 24 35 47 44 39 23 51 41 26 9 8 11 25 6 46 2 15 10 45 1 32 29 4 47 14 35 49 16 22 30 43 11 47 42 28 17 39 18 15 24 5 22 12 7 7 32 43 36 17 3 1 12 34 27 35 16 29 22 45 42 38 8 45 37 22 50 33 31 49 28 20 17 40 15 17 10 30 39 18 48 32 4 26 13 27 22 3 2 8 ...
output:
40 -360 185 235 400
result:
wrong answer 1st lines differ - expected: '25', found: '40'