結果

問題 No.2037 NAND Pyramid
ユーザー simansiman
提出日時 2022-11-28 20:14:05
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 142,068 KB
実行使用メモリ 9,012 KB
最終ジャッジ日時 2024-04-15 18:27:47
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 11 ms
6,976 KB
testcase_08 AC 12 ms
7,384 KB
testcase_09 AC 10 ms
6,940 KB
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 11 ms
6,944 KB
testcase_12 AC 6 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 9 ms
6,944 KB
testcase_15 AC 11 ms
7,192 KB
testcase_16 AC 9 ms
6,940 KB
testcase_17 AC 13 ms
8,464 KB
testcase_18 AC 13 ms
8,424 KB
testcase_19 AC 15 ms
8,668 KB
testcase_20 AC 15 ms
8,724 KB
testcase_21 AC 16 ms
8,996 KB
testcase_22 AC 16 ms
9,012 KB
testcase_23 AC 15 ms
8,948 KB
testcase_24 AC 16 ms
8,940 KB
testcase_25 AC 13 ms
8,364 KB
testcase_26 AC 14 ms
8,368 KB
testcase_27 AC 13 ms
8,624 KB
testcase_28 AC 14 ms
8,408 KB
testcase_29 AC 13 ms
8,292 KB
testcase_30 AC 16 ms
8,952 KB
testcase_31 AC 13 ms
8,580 KB
testcase_32 AC 15 ms
8,572 KB
testcase_33 AC 1 ms
6,944 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int colors[N][3];
  memset(colors, -1, sizeof(colors));

  for (int i = 0; i < N; ++i) {
    colors[i][0] = S[i] - '0';
  }
  
  for (int i = 1; i <= 2; ++i) {
    for (int j = 0; j < N - i; ++j) {
      colors[j][i] = !(colors[j][i - 1] & colors[j + 1][i - 1]);
    }
  }

  int offset = 0;
  int k = N - K;
  while (k >= 3) {
    k -= 2;
    offset += 1;
  }

  string ans = "";
  // fprintf(stderr, "k: %d\n", k);

  for (int i = 0; i < K; ++i) {
    if (colors[i + offset][k] == 0) {
      ans += '0';
    } else {
      ans += '1';
    }
  }

  cout << ans << endl;

  return 0;
}
0