結果

問題 No.102 トランプを奪え
ユーザー kuuso1kuuso1
提出日時 2014-12-15 23:06:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 2,048 bytes
コンパイル時間 3,364 ms
コンパイル使用メモリ 105,560 KB
実行使用メモリ 30,544 KB
最終ジャッジ日時 2023-09-02 14:54:15
合計ジャッジ時間 5,374 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
28,572 KB
testcase_01 AC 84 ms
28,544 KB
testcase_02 AC 85 ms
28,564 KB
testcase_03 AC 81 ms
26,560 KB
testcase_04 AC 82 ms
26,560 KB
testcase_05 AC 82 ms
30,544 KB
testcase_06 AC 84 ms
28,656 KB
testcase_07 AC 83 ms
26,664 KB
testcase_08 AC 82 ms
28,500 KB
testcase_09 AC 83 ms
26,476 KB
testcase_10 AC 85 ms
26,556 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Gr=new int[14][][][];
		for(int i=0;i<=13;i++){
			Gr[i]=new int[14][][];
			for(int j=0;j<=13;j++){
				Gr[i][j]=new int[14][];
				for(int k=0;k<=13;k++){
					Gr[i][j][k]=new int[14];
				}
			}
		}
		memo=new bool[14][][][];
		for(int i=0;i<=13;i++){
			memo[i]=new bool[14][][];
			for(int j=0;j<=13;j++){
				memo[i][j]=new bool[14][];
				for(int k=0;k<=13;k++){
					memo[i][j][k]=new bool[14];
				}
			}
		}
		
		Gr[0][0][0][0]=0;
		memo[0][0][0][0]=true;
		for(int i=0;i<=13;i++){
			for(int j=0;j<=13;j++){
				for(int k=0;k<=13;k++){
					for(int l=0;l<=13;l++){
						Gr[i][j][k][l]=dfs(i,j,k,l);
					}
				}
			}
		}
		
		Console.WriteLine(Gr[A[0]][A[1]][A[2]][A[3]]==0?"Jiro":"Taro");
		
		
		
		
	}
	int[][][][] Gr;
	bool[][][][] memo;
	
	int dfs(int i,int j,int k,int l){
		if(memo[i][j][k][l])return Gr[i][j][k][l];
		
		HashSet<int> H=new HashSet<int>();
		for(int t=1;t<=3;t++){
			if(i-t>=0)H.Add(dfs(i-t,j,k,l));
			if(j-t>=0)H.Add(dfs(i,j-t,k,l));
			if(k-t>=0)H.Add(dfs(i,j,k-t,l));
			if(l-t>=0)H.Add(dfs(i,j,k,l-t));
		}
		int g=0;
		while(H.Contains(g))g++;
		memo[i][j][k][l]=true;
		return Gr[i][j][k][l]=g;
	}
	
	
	int[] A;
	public Sol(){
		A=ria();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0