結果
| 問題 | No.102 トランプを奪え | 
| コンテスト | |
| ユーザー |  purple_jwl | 
| 提出日時 | 2015-03-23 23:58:58 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 48 ms / 5,000 ms | 
| コード長 | 1,713 bytes | 
| コンパイル時間 | 1,283 ms | 
| コンパイル使用メモリ | 159,224 KB | 
| 実行使用メモリ | 14,464 KB | 
| 最終ジャッジ日時 | 2024-06-29 00:26:52 | 
| 合計ジャッジ時間 | 2,223 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 | 
ソースコード
#include <bits/stdc++.h>
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
int memo[15][15][15][15][55];
int rec(int n1, int n2, int n3, int n4, int n, int total) {
  if(memo[n1][n2][n3][n4][n] != -1) return memo[n1][n2][n3][n4][n];
  int rival = total - n1 - n2 - n3 - n4 - n;
  int res = -1;
  int tmp;
  bool flg = false;
  REP(i, 1, 4) if(n1 >= i) {
    flg = true;
    tmp = 1;
    if(n1 == i) tmp = 2;
    res = max(res, abs(2 - rec(n1 - i, n2, n3, n4, rival / tmp, total)));
  }
  REP(i, 1, 4) if(n2 >= i) {
    flg = true;
    tmp = 1;
    if(n2 == i) tmp = 2;
    res = max(res, abs(2 - rec(n1, n2 - i, n3, n4, rival / tmp, total)));
  }
  REP(i, 1, 4) if(n3 >= i) {
    flg = true;
    tmp = 1;
    if(n3 == i) tmp = 2;
    res = max(res, abs(2 - rec(n1, n2, n3 - i, n4, rival / tmp, total)));
  }
  REP(i, 1, 4) if(n4 >= i) {
    flg = true;
    tmp = 1;
    if(n4 == i) tmp = 2;
    res = max(res, abs(2 - rec(n1, n2, n3, n4 - i, rival / tmp, total)));
  }
  if(!flg) {
    if(n > rival) res = 2;
    else if(n < rival) res = 0;
    else res = 1;
  }
  return memo[n1][n2][n3][n4][n] = res;
}
int main() {
  // ios_base::sync_with_stdio(false);
  int n1, n2, n3, n4;
  cin >> n1 >> n2 >> n3 >> n4;
  memset(memo, -1, sizeof(memo));
  int ans = rec(n1, n2, n3, n4, 0, n1 + n2 + n3 + n4);
  if(ans == 2) cout << "Taro" << endl;
  if(ans == 0) cout << "Jiro" << endl;
  if(ans == 1) cout << "Draw" << endl;
  return 0;
}
            
            
            
        