結果

問題 No.2037 NAND Pyramid
ユーザー MitarushiMitarushi
提出日時 2022-08-13 00:32:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,533 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 80,232 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-24 12:42:19
合計ジャッジ時間 21,252 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 444 ms
4,348 KB
testcase_08 AC 1,029 ms
4,348 KB
testcase_09 AC 301 ms
4,348 KB
testcase_10 AC 436 ms
4,348 KB
testcase_11 AC 156 ms
4,348 KB
testcase_12 AC 31 ms
4,348 KB
testcase_13 AC 116 ms
4,348 KB
testcase_14 AC 327 ms
4,348 KB
testcase_15 AC 704 ms
4,348 KB
testcase_16 AC 363 ms
4,348 KB
testcase_17 AC 1,533 ms
4,348 KB
testcase_18 AC 1,533 ms
4,348 KB
testcase_19 AC 1,148 ms
4,348 KB
testcase_20 AC 1,147 ms
4,348 KB
testcase_21 AC 16 ms
4,352 KB
testcase_22 AC 16 ms
4,352 KB
testcase_23 AC 16 ms
4,352 KB
testcase_24 AC 16 ms
4,352 KB
testcase_25 AC 1,524 ms
4,348 KB
testcase_26 AC 1,522 ms
4,348 KB
testcase_27 AC 1,147 ms
4,348 KB
testcase_28 AC 1,520 ms
4,348 KB
testcase_29 AC 1,522 ms
4,348 KB
testcase_30 AC 16 ms
4,352 KB
testcase_31 AC 1,147 ms
4,348 KB
testcase_32 AC 1,153 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 <iostream>
#include <string>
#include <cstdint>



int main() {
    int n, k;
    std::cin >> n >> k;
    std::string s;
    std::cin >> s;
    
    std::uint64_t dp[400200 / 64] = {};

    for (int i = 0; i < n; i++) {
        if (s[i] == '1') {
            dp[i / 64] |= 1ull << (i % 64);
        }
    }

    for (int i = n; i > k; i--) {
        for (int j = 0; j < i / 64 + 1; j++) {
            std::uint64_t c = dp[j] & (dp[j + 1] << 63);
            c |= dp[j] & (dp[j] >> 1);
            dp[j] = ~c;
        }
    }

    std::string t = "";
    for (int i = 0; i < k; i++) {
        if (dp[i / 64] & (1ull << (i % 64))) {
            t += '1';
        } else {
            t += '0';
        }
    }

    std::cout << t << std::endl;
}
0