結果

問題 No.1770 N言っちゃダメゲーム (6)
ユーザー ngtkanangtkana
提出日時 2020-06-11 02:00:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,152 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 207,744 KB
実行使用メモリ 14,156 KB
最終ジャッジ日時 2023-09-16 21:57:04
合計ジャッジ時間 4,419 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 25 ms
12,380 KB
testcase_11 AC 26 ms
12,516 KB
testcase_12 AC 25 ms
12,404 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 24 ms
12,172 KB
testcase_29 AC 13 ms
6,692 KB
testcase_30 AC 22 ms
11,272 KB
testcase_31 AC 11 ms
6,260 KB
testcase_32 AC 24 ms
13,616 KB
testcase_33 AC 29 ms
14,016 KB
testcase_34 AC 29 ms
13,940 KB
testcase_35 AC 28 ms
13,912 KB
testcase_36 AC 29 ms
13,976 KB
testcase_37 AC 27 ms
14,156 KB
testcase_38 AC 25 ms
13,972 KB
testcase_39 AC 25 ms
13,976 KB
testcase_40 AC 24 ms
13,992 KB
testcase_41 AC 25 ms
13,972 KB
testcase_42 AC 24 ms
14,128 KB
testcase_43 AC 25 ms
13,792 KB
testcase_44 AC 17 ms
10,176 KB
testcase_45 AC 25 ms
13,776 KB
testcase_46 AC 28 ms
13,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * 嘘解法
 * y + k への遷移を忘れる
 */
#include <bits/stdc++.h>

int main() {
    int n, k;
    std::cin >> n >> k;

    if (k==1) {
        std::cout << 1 << '\n';
        return 0;
    }

    std::vector<std::vector<int>> a(n+1);
    std::vector<int> b = {1};
    for (int i = 2; i <= n; i++) {
        auto&& v = a.at(i);
        int x = b.back();
        auto transite = [&](int j) {
            int d = i - j;
            if (d <= k && (a.at(j).empty()
                       || (a.at(j).size() == int{1} && a.at(j).front() == d)))
            {
                v.push_back(d);
            }
        };
        transite(x);
        transite((i + x) / 2);
        if (int{1} != b.size()) {
            int y = b.at(b.size() - 2);
            transite(y + k + 1);
            transite((i + y) / 2);
        }
        std::sort(v.begin(), v.end());
        v.resize(std::unique(v.begin(), v.end()) - v.begin()); if (v.empty()) b.push_back(i);
    }

    std::vector<int> ans = a.at(n);
    if (ans.empty()) {
        std::cout << 0 << '\n';
    } else {
        for (int x: ans) {
            std::cout << x << '\n';
        }
    }
}
0