結果

問題 No.361 門松ゲーム2
コンテスト
ユーザー nvt4s
提出日時 2019-04-30 03:05:03
言語 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  
実行時間 1,867 ms / 2,000 ms
コード長 923 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,825 ms
コンパイル使用メモリ 181,932 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-31 17:57:20
合計ジャッジ時間 5,494 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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; i++){
        for(int j = i+1; j < L; j++){
            for(int k = j+1; k < L; k++){
                if(i + j + k == L && k - i <= D){
                   s.insert(grundy(i, D) xor grundy(j, D) xor grundy(k, D));
                }else{
                    continue;
                }
            }
        }
    }
    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