結果

問題 No.102 トランプを奪え
ユーザー Manuel1024Manuel1024
提出日時 2021-07-03 00:43:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 838 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 77,992 KB
実行使用メモリ 4,552 KB
最終ジャッジ日時 2023-09-12 01:02:36
合計ジャッジ時間 1,771 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,552 KB
testcase_04 AC 3 ms
4,460 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,396 KB
testcase_09 AC 8 ms
4,384 KB
testcase_10 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

vector<vector<vector<vector<int>>>> dp(20, vector<vector<vector<int>>>(20,
vector<vector<int>>(20, vector<int>(20, -1))));

bool f(vector<int> &n){
    if(dp[n[0]][n[1]][n[2]][n[3]] != -1) return dp[n[0]][n[1]][n[2]][n[3]];

    vector<int> cnt(30, 0);
    for(int i = 0; i < 4; i++){
        int org = n[i];
        for(int j = 1; j <= 3 && n[i] > 0; j++){
            n[i]--;
            cnt[f(n)]++;
        }
        n[i] = org;
    }

    for(int i = 0; i < 30; i++){
        if(cnt[i] == 0){
            dp[n[0]][n[1]][n[2]][n[3]] = i;
            break;
        }
    }
    return dp[n[0]][n[1]][n[2]][n[3]];
}

int main(){
    vector<int> n(4);
    for(auto &p: n) cin >> p;
    
    if(f(n) == 0) cout << "Jiro" << endl;
    else cout << "Taro" << endl;
    return 0;
}
0