結果

問題 No.102 トランプを奪え
ユーザー beetbeet
提出日時 2019-03-05 11:52:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 1,282 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 199,656 KB
実行使用メモリ 15,436 KB
最終ジャッジ日時 2023-09-05 18:44:44
合計ジャッジ時間 2,761 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
15,276 KB
testcase_01 AC 6 ms
15,240 KB
testcase_02 AC 8 ms
15,436 KB
testcase_03 AC 6 ms
15,180 KB
testcase_04 AC 6 ms
15,176 KB
testcase_05 AC 11 ms
15,224 KB
testcase_06 AC 10 ms
15,364 KB
testcase_07 AC 7 ms
15,232 KB
testcase_08 AC 13 ms
15,280 KB
testcase_09 AC 52 ms
15,296 KB
testcase_10 AC 48 ms
15,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0