結果

問題 No.102 トランプを奪え
ユーザー Manuel1024
提出日時 2021-07-03 00:43:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 838 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 77,696 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 14:09:00
合計ジャッジ時間 1,599 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

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