結果

問題 No.102 トランプを奪え
ユーザー mamekinmamekin
提出日時 2015-01-18 00:29:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 240 ms / 5,000 ms
コード長 1,410 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 91,464 KB
実行使用メモリ 11,092 KB
最終ジャッジ日時 2023-09-04 21:25:09
合計ジャッジ時間 2,041 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,076 KB
testcase_01 AC 5 ms
11,068 KB
testcase_02 AC 9 ms
10,972 KB
testcase_03 AC 5 ms
11,088 KB
testcase_04 AC 6 ms
10,940 KB
testcase_05 AC 24 ms
11,012 KB
testcase_06 AC 20 ms
11,092 KB
testcase_07 AC 9 ms
11,088 KB
testcase_08 AC 28 ms
11,072 KB
testcase_09 AC 240 ms
10,952 KB
testcase_10 AC 216 ms
11,088 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;

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