結果

問題 No.361 門松ゲーム2
ユーザー nvt4s
提出日時 2019-04-30 03:07:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 1,444 ms
コンパイル使用メモリ 164,688 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 00:33:01
合計ジャッジ時間 2,588 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;
vector<int> memo(510, -1);
int grundy(int L, int D){
    if(memo[L] != -1){
        return memo.at(L);
    }
    
    set<int> s;
    for(int i = 1; i < L/3; i++){
        for(int j = i+1; j < L/2; j++){
            int k = L - i - j;
            if(k - i > D || j >= k) continue;
            s.insert(grundy(i, D) xor grundy(j, D) xor grundy(k, D));
        }
    }
    int res = 0;
    while(s.count(res)) res++;
    return memo.at(L) = res;
    
}

int main() {
    int L,D;
    cin >> L >> D;
    for(int i = 0; i < 510; i++) memo.at(L) = -1;
    if(grundy(L, D)){
        cout << "kado" << endl;
    }else{
        cout << "matsu" << endl;
    }
    
}
0