結果

問題 No.102 トランプを奪え
ユーザー たこしたこし
提出日時 2015-06-12 17:01:17
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,742 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 89,112 KB
実行使用メモリ 7,704 KB
最終ジャッジ日時 2023-09-20 21:03:25
合計ジャッジ時間 7,333 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 187 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>

#define INF_MIN 100000000
#define INF 1145141919
#define INF_MAX 2147483647
#define LL_MAX 9223372036854775807
#define EPS 1e-10
#define PI acos(-1)
#define LL long long

using namespace std;

typedef pair<LL, LL> P;

#define MAX_N 13

int N[4];

//0:Taro 1:Jiro
int memo[2][MAX_N][MAX_N][MAX_N][MAX_N];

int solve(int turn, int a, int b, int c, int d){

  if(memo[turn][a][b][c][d])
    return memo[turn][a][b][c][d];

  int nextTurn = (turn + 1) % 2;

  if((a || b || c || d) == 0)
    return nextTurn;

  for(int sub = 1; sub <= 3; sub++){

    if(a-sub >= 0){
      if(solve(nextTurn, a-sub, b, c, d) == turn){
	return memo[turn][a][b][c][d] = turn;
      }
    }
    
    if(b-sub >= 0){
      if(solve(nextTurn, a, b-sub, c, d) == turn){
	return memo[turn][a][b][c][d] = turn;
      }
    }

    if(c-sub >= 0){
      if(solve(nextTurn, a, b, c-sub, d) == turn){
	return memo[turn][a][b][c][d] = turn;
      }
    }

    if(d-sub >= 0){
      if(solve(nextTurn, a, b, c, d-sub) == turn){
	return memo[turn][a][b][c][d] = turn;
      }
    }

  }

  return memo[turn][a][b][c][d] = nextTurn;

}

int main(){

  int ans = 0;

  for(int i = 0; i < 4; i++){
    cin >> N[i];
  }

  if(solve(0, N[0], N[1], N[2], N[3]) == 0)
    cout << "Taro" << endl;
  else
    cout << "Jiro" << endl;

  return 0;

}
0