結果

問題 No.102 トランプを奪え
ユーザー ttttan2ttttan2
提出日時 2019-12-09 23:02:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,553 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 147,072 KB
実行使用メモリ 425,188 KB
最終ジャッジ日時 2023-09-05 12:12:33
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
424,940 KB
testcase_01 AC 192 ms
424,920 KB
testcase_02 AC 192 ms
424,924 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 197 ms
424,940 KB
testcase_07 WA -
testcase_08 AC 201 ms
424,908 KB
testcase_09 AC 484 ms
424,904 KB
testcase_10 AC 459 ms
424,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int dp[14][14][14][14][53][53];
int dfs(int a,int b,int c,int d,int s,int t){
    if(dp[a][b][c][d][s][t]>-1000000000)return dp[a][b][c][d][s][t];
    if(a==0&&b==0&&c==0&&d==0)return dp[a][b][c][d][s][t]=s-t;
    
    int ma=-1000000000;
    
    if(a>0){
        rep(i,1,a-1){
            ma=max(ma,-dfs(a-i,b,c,d,t,s+i));
        }
        int u=t-t/2;
        ma=max(ma,-dfs(0,b,c,d,t/2,s+u+a));
    }
    if(b>0){
        rep(i,1,b-1){
            ma=max(ma,-dfs(a,b-i,c,d,t,s+i));
        }
        int u=t-t/2;
        ma=max(ma,-dfs(a,0,c,d,t/2,s+u+b));
    }
    if(c>0){
        rep(i,1,c-1){
            ma=max(ma,-dfs(a,b,c-i,d,t,s+i));
        }
        int u=t-t/2;
        ma=max(ma,-dfs(a,b,0,d,t/2,s+u+c));
    }
    if(d>0){
        rep(i,1,d-1){
            ma=max(ma,-dfs(a,b,c,d-i,t,s+i));
        }
        int u=t-t/2;
        ma=max(ma,-dfs(a,b,c,0,t/2,s+u+d));
    }
    return dp[a][b][c][d][s][t]=ma;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int a[4];
    rep(i,0,14)rep(j,0,14)rep(k,0,14)rep(l,0,14)
    rep(x,0,53)rep(y,0,53)dp[i][j][k][l][x][y]=-1000000000;
    rep(i,0,4)cin>>a[i];
    int ans=dfs(a[0],a[1],a[2],a[3],0,0);
    if(ans>0)cout<<"Taro"<<endl;
    else if(ans==0)cout<<"Draw"<<endl;
    else cout<<"Jiro"<<endl;
    //cout<<ans<<endl;
}
0