結果

問題 No.102 トランプを奪え
ユーザー FF256grhyFF256grhy
提出日時 2017-07-12 15:36:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 2,332 bytes
コンパイル時間 1,363 ms
コンパイル使用メモリ 161,224 KB
実行使用メモリ 13,388 KB
最終ジャッジ日時 2024-04-16 17:50:44
合計ジャッジ時間 2,298 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 11 ms
7,936 KB
testcase_06 AC 10 ms
8,064 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 90 ms
13,388 KB
testcase_10 AC 80 ms
13,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n[4], s;
bool f[14 * 14 * 14 * 14][53];
int  v[14 * 14 * 14 * 14][53];

int ix(int x[4]) { return x[3] * 14 * 14 * 14 + x[2] * 14 * 14 + x[1] * 14 + x[0]; }

int dfs(int x[4], int a, int b) {
	if(f[ ix(x) ][a]) { return v[ ix(x) ][a]; }
	f[ ix(x) ][a] = true;
	
	int r = 777;
	if(a + b == s) {
		if(a >  b) { r = 0; }
		if(a == b) { r = 1; }
		if(a <  b) { r = 2; }
		return v[ ix(x) ][a] = r;
	}
	
	inc(i, 4) {
	inc1(j, 3) {
		if(x[i] < j) { continue; }
		x[i] -= j;
		int g = (x[i] ? 0 : b - b / 2);
		setmin(r, 2 - dfs(x, b - g, a + j + g));
		x[i] += j;
	}
	}
	return v[ ix(x) ][a] = r;
}

int main() {
	inc(i, 4) { cin >> n[i]; }
	
	inc(i, 4) { s += n[i]; }
	string s[3] = { "Taro", "Draw", "Jiro" };
	
	cout << s[dfs(n, 0, 0)] << endl;
	
	return 0;
}
0