結果
| 問題 | No.102 トランプを奪え | 
| コンテスト | |
| ユーザー |  tkzw_21 | 
| 提出日時 | 2015-01-05 20:36:40 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 5,000 ms | 
| コード長 | 1,347 bytes | 
| コンパイル時間 | 599 ms | 
| コンパイル使用メモリ | 64,792 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-13 02:42:19 | 
| 合計ジャッジ時間 | 1,615 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 | 
ソースコード
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <utility>
#define INF INT_MAX / 2
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int memo[2][14][14][14][14];
bool dfs(int t,int n1,int n2,int n3,int n4){
	if(memo[t%2][n1][n2][n3][n4] != 0){
		if(memo[t%2][n1][n2][n3][n4] == 1)return true;
		else return false;
	}
	if(n1+n2+n3+n4==0)return t%2==0?false:true;
	bool ret;
	if(t%2==0){
	ret = false;
	for(int i=1;i<=3;i++){
		if(n1-i>=0)ret |= dfs(t+1,n1-i,n2,n3,n4);
		if(n2-i>=0)ret |= dfs(t+1,n1,n2-i,n3,n4);
		if(n3-i>=0)ret |= dfs(t+1,n1,n2,n3-i,n4);
		if(n4-i>=0)ret |= dfs(t+1,n1,n2,n3,n4-i);
	}
	}	
	else{
	ret = true;
	for(int i=1;i<=3;i++){
		if(n1-i>=0)ret &= dfs(t+1,n1-i,n2,n3,n4);
		if(n2-i>=0)ret &= dfs(t+1,n1,n2-i,n3,n4);
		if(n3-i>=0)ret &= dfs(t+1,n1,n2,n3-i,n4);
		if(n4-i>=0)ret &= dfs(t+1,n1,n2,n3,n4-i);
	}
	}
	if(ret)memo[t%2][n1][n2][n3][n4] = 1;
	else memo[t%2][n1][n2][n3][n4] = -1;
	return ret;
}
int main(void) {
	int n1,n2,n3,n4;
	cin >> n1 >> n2 >> n3 >> n4;
	if(dfs(0,n1,n2,n3,n4))cout << "Taro" << endl;
	else cout << "Jiro" << endl;
}
// command shift d duplicate
// command ctrl 上下
// command D
// command caps G → '' ""
// vector<vector<int>> a(N,vector<int>(M,-1));
            
            
            
        