結果
| 問題 |
No.102 トランプを奪え
|
| コンテスト | |
| ユーザー |
たこし
|
| 提出日時 | 2015-06-12 17:03:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,783 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 90,472 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 15:51:39 |
| 合計ジャッジ時間 | 1,489 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 RE * 1 |
ソースコード
#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] != -1)
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(){
memset(memo, -1, sizeof(memo));
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;
}
たこし