結果
問題 | No.102 トランプを奪え |
ユーザー | koba-e964 |
提出日時 | 2015-06-18 13:34:56 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 119 ms / 5,000 ms |
コード長 | 1,500 bytes |
コンパイル時間 | 369 ms |
コンパイル使用メモリ | 54,012 KB |
実行使用メモリ | 19,568 KB |
最終ジャッジ日時 | 2023-09-21 09:25:51 |
合計ジャッジ時間 | 1,873 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
19,240 KB |
testcase_01 | AC | 7 ms
19,244 KB |
testcase_02 | AC | 9 ms
19,568 KB |
testcase_03 | AC | 7 ms
19,244 KB |
testcase_04 | AC | 7 ms
19,568 KB |
testcase_05 | AC | 16 ms
19,316 KB |
testcase_06 | AC | 14 ms
19,440 KB |
testcase_07 | AC | 9 ms
19,324 KB |
testcase_08 | AC | 21 ms
19,268 KB |
testcase_09 | AC | 119 ms
19,252 KB |
testcase_10 | AC | 117 ms
19,384 KB |
ソースコード
#include <cstdlib> #include <cstring> #include <iostream> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; const double EPS=1e-9; int dn[4]; const int S = 13; int dp[4 * S + 1][S + 1][S + 1][S + 1][S + 1][2] = {}; int rec(int th, int jh, int a, int b, int c, int d, int w) { int &ret = dp[jh][a][b][c][d][w]; if (ret >= 0) { return ret; } int res = 1; if (a + b + c + d == 0) { return ret = w ? th >= jh : th > jh; } if (a > 0) { REP(i, 1, 4) { if (a == i) { res &= rec(jh / 2, th + jh - jh / 2 + i, 0, b, c, d, 1 - w); } if (a > i) { res &= rec(jh, th + i, a - i, b, c, d, 1 - w); } } } if (b > 0) { REP(i, 1, 4) { if (b == i) { res &= rec(jh / 2, th + jh - jh / 2 + i, a, 0, c, d, 1 - w); } if (b > i) { res &= rec(jh, th + i, a, b - i, c, d, 1 - w); } } } if (c > 0) { REP(i, 1, 4) { if (c == i) { res &= rec(jh / 2, th + jh - jh / 2 + i, a, b, 0, d, 1 - w); } if (c > i) { res &= rec(jh, th + i, a, b, c - i, d, 1 - w); } } } if (d > 0) { REP(i, 1, 4) { if (d == i) { res &= rec(jh / 2, th + jh - jh / 2 + i, a, b, c, 0, 1 - w); } if (d > i) { res &= rec(jh, th + i, a, b, c, d - i, 1 - w); } } } return ret = 1 - res; } int main(void){ REP(i, 0, 4) { cin >> dn[i]; } memset(dp, -1, sizeof(dp)); cout << (rec(0, 0, dn[0], dn[1], dn[2], dn[3], 0) ? "Taro" : "Jiro") << endl; }