結果

問題 No.361 門松ゲーム2
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-09-13 22:19:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,306 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 176,028 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 13:15:09
合計ジャッジ時間 2,387 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int L, D;
    void input() {
        cin >> L >> D;
    }

    map<pair<int, int>, int> cache;
    bool dfs(int x, int w) {
        auto key = make_pair(x, w);
        if (cache.count(key)) return cache[key];
        for (int a = 1; a <= x; a++) {
            for (int b = a; a + b <= x; b++) {
                int c = x - a - b;
                if (c < b) continue;
                if (c - a > D) continue;
                if (a == b || b == c || c == a) continue;
                if (not (dfs(a, !w) or dfs(b, !w) or dfs(c, !w))) return cache[key] = true;
            }
        }
        return cache[key] = false;
    }

    void solve() {
        cout << (dfs(L, 0) ? "kado" : "matsu")  << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

0