結果
| 問題 | No.102 トランプを奪え | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-10-18 04:30:00 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 59 ms / 5,000 ms | 
| コード長 | 1,152 bytes | 
| コンパイル時間 | 788 ms | 
| コンパイル使用メモリ | 65,868 KB | 
| 実行使用メモリ | 13,312 KB | 
| 最終ジャッジ日時 | 2024-06-25 14:00:49 | 
| 合計ジャッジ時間 | 1,565 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 | 
コンパイルメッセージ
main.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
using namespace std;
bool vis[14][14][14][14][53];
int memo[14][14][14][14][53];
int SUM;
int dfs(int A,int B,int C,int D,int S)
{
	if(vis[A][B][C][D][S])return memo[A][B][C][D][S];
	vis[A][B][C][D][S]=true;
	int T=SUM-A-B-C-D-S;
	int ans=-1;
	if(A==0&&B==0&&C==0&&D==0)
	{
		if(S>T)ans=1;
		else if(S==T)ans=0;
		else ans=-1;
	}
	else
	{
		for(int i=1;i<=A&&i<=3;i++)
		{
			int s=S+i,t=T;
			if(i==A)s+=(t+1)/2,t/=2;
			int x=dfs(A-i,B,C,D,t);
			if(x<0)ans=1;
			else if(x==0&&ans<0)ans=0;
		}
		for(int i=1;i<=B&&i<=3;i++)
		{
			int s=S+i,t=T;
			if(i==B)s+=(t+1)/2,t/=2;
			int x=dfs(A,B-i,C,D,t);
			if(x<0)ans=1;
			else if(x==0&&ans<0)ans=0;
		}
		for(int i=1;i<=C&&i<=3;i++)
		{
			int s=S+i,t=T;
			if(i==C)s+=(t+1)/2,t/=2;
			int x=dfs(A,B,C-i,D,t);
			if(x<0)ans=1;
			else if(x==0&&ans<0)ans=0;
		}
		for(int i=1;i<=D&&i<=3;i++)
		{
			int s=S+i,t=T;
			if(i==D)s+=(t+1)/2,t/=2;
			int x=dfs(A,B,C,D-i,t);
			if(x<0)ans=1;
			else if(x==0&&ans<0)ans=0;
		}
	}
	return memo[A][B][C][D][S]=ans;
}
main()
{
	int A,B,C,D;cin>>A>>B>>C>>D;
	SUM=A+B+C+D;
	int X=dfs(A,B,C,D,0);
	cout<<(X>0?"Taro":X==0?"Draw":"Jiro")<<endl;
}
            
            
            
        