結果

問題 No.361 門松ゲーム2
ユーザー mayoko_mayoko_
提出日時 2016-04-20 18:55:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,328 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 107,360 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 07:20:24
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 50 ms
6,940 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 16 ms
6,940 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 17 ms
6,944 KB
testcase_22 AC 145 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,948 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 6 ms
6,940 KB
testcase_27 AC 9 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXL = 555;
int g[MAXL], D;

int grundy(int L) {
    int& ret = g[L];
    if (ret >= 0) return ret;
    set<int> S;
    for (int l1 = 1; l1 < L/3; l1++) for (int l2 = l1+1; l2+l1 < L; l2++) {
        int l3 = L-l1-l2;
        if (l3 <= l2) break;
        if (l3-l1 > D) continue;
        int g1 = grundy(l1), g2 = grundy(l2), g3 = grundy(l3);
        S.insert(g1^g2^g3);
    }
    ret = 0;
    while (1) {
        if (S.find(ret) == S.end()) return ret;
        ret++;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L;
    cin >> L >> D;
    memset(g, -1, sizeof(g));
    if (grundy(L) == 0) cout << "matsu" << endl;
    else cout << "kado" << endl;
    return 0;
}
0