結果

問題 No.102 トランプを奪え
ユーザー Ryushi-techRyushi-tech
提出日時 2021-05-12 23:19:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,396 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 201,568 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 18:06:17
合計ジャッジ時間 2,765 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return false;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return false;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

int a[5],memo[14][14][14][14];

int win(){
    int& ret= memo[a[0]][a[1]][a[2]][a[3]];
    if(a[0]== 0 and a[1]==0 and a[2]==0 and a[3]==0) return 0;
    if(ret==-1){
        ret=0;
        rep(j,4){
            for(int i=1;i<=min(a[j],3);i++){
                a[j]-=i;
                if(win()==0)ret=1;
                a[j]+=i;
            }
        }
    }
    return ret;
}

int main() {
    fio(); cin>>a[0]>>a[1]>>a[2]>>a[3];
    memset(memo,0xff,sizeof(memo));
    if(win()) print("Taro");
    else print("Jiro");
}
0