結果
| 問題 |
No.102 トランプを奪え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-18 00:29:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 246 ms / 5,000 ms |
| コード長 | 1,410 bytes |
| コンパイル時間 | 1,236 ms |
| コンパイル使用メモリ | 93,508 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-06-22 18:53:21 |
| 合計ジャッジ時間 | 1,968 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
vector<int> memo;
int solve(const vector<int>& x)
{
if(accumulate(x.begin(), x.begin() + 4, 0) == 0)
return x[4] - x[5];
int hash = x[4];
for(int i=0; i<4; ++i){
hash *= 14;
hash += x[i];
}
if(memo[hash] != -1)
return memo[hash];
int ret = INT_MIN;
for(int i=0; i<4; ++i){
for(int j=1; j<=min(3, x[i]); ++j){
vector<int> y = x;
y[i] -= j;
y[4] += j;
if(y[i] == 0){
int a = (y[5] + 1) / 2;
y[4] += a;
y[5] -= a;
}
swap(y[4], y[5]);
ret = max(ret, -solve(y));
}
}
return memo[hash] = ret;
}
int main()
{
vector<int> x(6, 0);
for(int i=0; i<4; ++i)
cin >> x[i];
memo.assign(14*14*14*14*53, -1);
int ret = solve(x);
if(ret > 0)
cout << "Taro" << endl;
else if(ret == 0)
cout << "Draw" << endl;
else
cout << "Jiro" << endl;
return 0;
}