結果

問題 No.2037 NAND Pyramid
ユーザー noiminoimi
提出日時 2022-08-12 23:55:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,076 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 203,048 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-24 12:12:00
合計ジャッジ時間 11,364 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 411 ms
4,348 KB
testcase_01 AC 409 ms
4,348 KB
testcase_02 AC 408 ms
4,348 KB
testcase_03 AC 408 ms
4,348 KB
testcase_04 AC 409 ms
4,348 KB
testcase_05 AC 411 ms
4,348 KB
testcase_06 AC 409 ms
4,348 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)

bool dp[2][400100];

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

    constexpr int B = 20;
    vector<bool> v(1 << B);
    rep(i, 1 << B) {
        int now = i;
        rep(j, B - 1) {
            int nxt = 0;
            rep(k, B - j - 1) { nxt |= (1 - ((now >> k & 1) & (now >> k + 1 & 1))) << k; }
            now = nxt;
        }
        v[i] = now;
    }

    string s;
    cin >> s;
    rep(i, n) dp[0][i] = (s[i] - '0');
    int x = 0;
    while(n > k) {
        if(n - (B - 1) >= k) {
            int nn = n - (B - 1);
            unsigned s = 0;
            rep(i, B) s = (s << 1) + dp[x][i];
            rep(i, nn) {
                dp[x ^ 1][i] = v[s & ((1 << B) - 1)];
                s = (s << 1) + dp[x][i + B];
            }
            x ^= 1;
            n = nn;
        } else {
            rep(i, n - 1) { dp[x ^ 1][i] = (1 - (dp[x][i] & dp[x][i + 1])); }
            x ^= 1;
            n--;
        }
    }
    rep(i, k) cout << dp[x][i];
    cout << endl;
}
0