結果

問題 No.102 トランプを奪え
ユーザー kotatsugamekotatsugame
提出日時 2019-10-18 04:30:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 1,152 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 66,644 KB
実行使用メモリ 13,420 KB
最終ジャッジ日時 2023-09-07 20:14:54
合計ジャッジ時間 2,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 4 ms
4,724 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 9 ms
7,472 KB
testcase_06 AC 8 ms
6,860 KB
testcase_07 AC 4 ms
6,056 KB
testcase_08 AC 12 ms
9,904 KB
testcase_09 AC 68 ms
13,420 KB
testcase_10 AC 63 ms
12,980 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:55:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   55 | main()
      | ^~~~

ソースコード

diff #

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