結果
問題 | No.102 トランプを奪え |
ユーザー |
|
提出日時 | 2015-01-18 00:26:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3,757 ms / 5,000 ms |
コード長 | 1,289 bytes |
コンパイル時間 | 1,109 ms |
コンパイル使用メモリ | 102,244 KB |
実行使用メモリ | 71,040 KB |
最終ジャッジ日時 | 2024-06-22 18:53:18 |
合計ジャッジ時間 | 9,810 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; map<vector<int>, int> memo; int solve(const vector<int>& x) { if(accumulate(x.begin(), x.begin() + 4, 0) == 0) return x[4] - x[5]; if(memo.find(x) != memo.end()) return memo[x]; 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[x] = ret; } int main() { vector<int> x(6, 0); for(int i=0; i<4; ++i) cin >> x[i]; int ret = solve(x); if(ret > 0) cout << "Taro" << endl; else if(ret == 0) cout << "Draw" << endl; else cout << "Jiro" << endl; return 0; }