結果

問題 No.102 トランプを奪え
ユーザー mamekinmamekin
提出日時 2015-01-18 00:26:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,708 ms / 5,000 ms
コード長 1,289 bytes
コンパイル時間 1,672 ms
コンパイル使用メモリ 99,312 KB
実行使用メモリ 71,056 KB
最終ジャッジ日時 2023-09-04 21:25:05
合計ジャッジ時間 10,087 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 49 ms
5,208 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 221 ms
9,656 KB
testcase_06 AC 180 ms
8,752 KB
testcase_07 AC 39 ms
4,908 KB
testcase_08 AC 266 ms
10,948 KB
testcase_09 AC 3,708 ms
71,056 KB
testcase_10 AC 3,328 ms
65,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0