結果

問題 No.361 門松ゲーム2
コンテスト
ユーザー nvt4s
提出日時 2019-04-30 03:07:24
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 820 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,100 ms
コンパイル使用メモリ 182,312 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-31 17:58:01
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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