結果
| 問題 | No.102 トランプを奪え | 
| コンテスト | |
| ユーザー |  hotpepsi | 
| 提出日時 | 2014-12-15 00:19:09 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 854 bytes | 
| コンパイル時間 | 624 ms | 
| コンパイル使用メモリ | 65,432 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-11 21:10:39 | 
| 合計ジャッジ時間 | 964 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <string.h>
using namespace std;
int memo[16][16][16][16];
int dfs(int *N)
{
	int a[4] = { N[0], N[1], N[2], N[3] };
	sort(a, a + 4);
	if (memo[a[0]][a[1]][a[2]][a[3]] >= 0) {
		return memo[a[0]][a[1]][a[2]][a[3]];
	}
	if (a[2] == 0 && a[3] <= 3) {
		return 1;
	}
	int w = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = 1; j <= 3; ++j) {
			if (a[i] >= j) {
				a[i] -= j;
				if (dfs(a) == 0) {
					w = 1;
				}
				a[i] += j;
			}
		}
	}
	memo[a[0]][a[1]][a[2]][a[3]] = w;
	return w;
}
int main(int argc, char *argv[])
{
	memset(memo, -1, sizeof(memo));
	string s;
	getline(cin, s);
	stringstream ss(s);
	int N[4];
	ss >> N[0] >> N[1] >> N[2] >> N[3];
	cout << (dfs(N) ? "Taro" : "Jiro") << endl;
	return 0;
}
            
            
            
        