結果

問題 No.2037 NAND Pyramid
ユーザー CyanmondCyanmond
提出日時 2022-08-12 22:02:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 208,576 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 10:03:31
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 31 ms
4,348 KB
testcase_08 AC 26 ms
4,348 KB
testcase_09 AC 28 ms
4,348 KB
testcase_10 AC 16 ms
4,348 KB
testcase_11 AC 33 ms
4,348 KB
testcase_12 AC 18 ms
4,348 KB
testcase_13 AC 10 ms
4,348 KB
testcase_14 AC 21 ms
4,348 KB
testcase_15 AC 30 ms
4,348 KB
testcase_16 AC 19 ms
4,348 KB
testcase_17 AC 28 ms
4,348 KB
testcase_18 AC 28 ms
4,348 KB
testcase_19 AC 42 ms
4,348 KB
testcase_20 AC 43 ms
4,348 KB
testcase_21 AC 51 ms
4,348 KB
testcase_22 AC 50 ms
4,348 KB
testcase_23 AC 54 ms
4,348 KB
testcase_24 AC 54 ms
4,348 KB
testcase_25 AC 31 ms
4,348 KB
testcase_26 AC 28 ms
4,348 KB
testcase_27 AC 43 ms
4,348 KB
testcase_28 AC 31 ms
4,348 KB
testcase_29 AC 28 ms
4,348 KB
testcase_30 AC 66 ms
4,348 KB
testcase_31 AC 40 ms
4,348 KB
testcase_32 AC 43 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

std::vector<bool> naive(std::vector<bool> s) {
    const int N = (int)s.size();
    std::vector<bool> new_s(N - 1);
    for (int i = 0; i < N - 1; ++i) new_s[i] = (s[i] and s[i + 1]) ? false : true;
    return new_s;
}

int main() {
    int N, K; std::cin >> N >> K;
    std::vector<bool> S(N);
    for (int i = 0; i < N; ++i) {
        char c; std::cin >> c;
        S[i] = (bool)(c == '1');
    }

    // 1
    if (N - K < 10) {
        while (K != N) {
            S = naive(S);
            ++K;
        }
    } else {
        int c = N - K - 1;
        S = naive(S);
        if (c % 2 == 1) S = naive(S);
        c /= 2;
        std::vector<bool> ans;
        for (int i = c; (int)ans.size() != K; ++i) ans.push_back(S[i]);
        S = ans;
    }
    for (const auto e : S) std::cout << e;
    std::cout << std::endl;
}
0