結果
問題 | No.102 トランプを奪え |
ユーザー |
![]() |
提出日時 | 2019-03-05 11:52:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 5,000 ms |
コード長 | 1,282 bytes |
コンパイル時間 | 1,727 ms |
コンパイル使用メモリ | 194,440 KB |
最終ジャッジ日時 | 2025-01-06 21:58:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE int dp[60][15][15][15][15]; int a,b,c,d; int dfs(int t,int w,int x,int y,int z){ int &res=dp[t][w][x][y][z]; if(~res) return res; res=0; int cnt=(a-w)+(b-x)+(c-y)+(d-z); if(cnt==a+b+c+d){ if(t<(cnt-t)) res=0; if(t==(cnt-t)) res=1; if(t>(cnt-t)) res=2; return res; } for(int i=1;i<=3;i++){ if(w-i>=0){ int num=cnt-t; if(w-i==0) num/=2; chmax(res,2-dfs(num,w-i,x,y,z)); } if(x-i>=0){ int num=cnt-t; if(x-i==0) num/=2; chmax(res,2-dfs(num,w,x-i,y,z)); } if(y-i>=0){ int num=cnt-t; if(y-i==0) num/=2; chmax(res,2-dfs(num,w,x,y-i,z)); } if(z-i>=0){ int num=cnt-t; if(z-i==0) num/=2; chmax(res,2-dfs(num,w,x,y,z-i)); } } //cout<<t<<":"<<w<<" "<<x<<" "<<y<<" "<<z<<":"<<res<<endl; return res; } signed main(){ memset(dp,-1,sizeof(dp)); cin>>a>>b>>c>>d; int k=dfs(0,a,b,c,d); if(k==0) cout<<"Jiro"<<endl; if(k==1) cout<<"Draw"<<endl; if(k==2) cout<<"Taro"<<endl; return 0; }