結果

問題 No.102 トランプを奪え
ユーザー 沙耶花沙耶花
提出日時 2021-10-26 15:25:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 1,573 bytes
コンパイル時間 4,523 ms
コンパイル使用メモリ 255,176 KB
実行使用メモリ 11,624 KB
最終ジャッジ日時 2024-04-15 14:21:49
合計ジャッジ時間 5,250 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,504 KB
testcase_01 AC 5 ms
11,560 KB
testcase_02 AC 6 ms
11,440 KB
testcase_03 AC 6 ms
11,492 KB
testcase_04 AC 5 ms
11,456 KB
testcase_05 AC 10 ms
11,544 KB
testcase_06 AC 8 ms
11,624 KB
testcase_07 AC 6 ms
11,548 KB
testcase_08 AC 10 ms
11,444 KB
testcase_09 AC 49 ms
11,528 KB
testcase_10 AC 43 ms
11,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000

int N[4];
int S = 0;

int dp[14][14][14][14][53];

int get(int a,int b,int c,int d,int e){
	if(dp[a][b][c][d][e]!=-1)return dp[a][b][c][d][e];
	
	int me = e,opp = S-a-b-c-d-e;
	int ret = -Inf;
	for(int i=1;i<=3;i++){
		if(i<=a){
			int temp = me - opp + i;
			int ee = opp;
			if(a-i==0){
				temp += ((opp+1)/2)*2;
				ee = (ee+1)/2;
			}
			temp -= get(a-i,b,c,d,ee);
			ret = max(ret,temp);
		}
	}
	for(int i=1;i<=3;i++){
		if(i<=b){
			int temp = me - opp + i;
			int ee = opp;
			if(b-i==0){
				temp += ((opp+1)/2)*2;
				ee = (ee+1)/2;
			}
			temp -= get(a,b-i,c,d,ee);
			ret = max(ret,temp);
		}
	}
	for(int i=1;i<=3;i++){
		if(i<=c){
			int temp = me - opp + i;
			int ee = opp;
			if(c-i==0){
				temp += ((opp+1)/2)*2;
				ee = (ee+1)/2;
			}
			temp -= get(a,b,c-i,d,ee);
			ret = max(ret,temp);
		}
	}
	for(int i=1;i<=3;i++){
		if(i<=d){
			int temp = me - opp + i;
			int ee = opp;
			if(d-i==0){
				temp += ((opp+1)/2)*2;
				ee = (ee+1)/2;
			}
			temp -= get(a,b,c,d-i,ee);
			ret = max(ret,temp);
		}
	}
	dp[a][b][c][d][e] = ret;
	return ret;
	
}
	

int main(){
	
	rep(i,4){
		cin>>N[i];
		S += N[i];
	}
	
	rep(i,14){
		rep(j,14){
			rep(k,14){
				rep(l,14){
					rep(ll,53)dp[i][j][k][l][ll] = -1;
				}
			}
		}
	}
	
	int Ans = get(N[0],N[1],N[2],N[3],0);
	if(Ans == 0)cout<<"Draw"<<endl;
	else if(Ans>0)cout<<"Taro"<<endl;
	else cout<<"Jiro"<<endl;
	
	
	
	return 0;
}
0