結果
問題 | No.2037 NAND Pyramid |
ユーザー |
![]() |
提出日時 | 2022-08-16 02:59:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 41,856 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-10-02 14:42:51 |
合計ジャッジ時間 | 2,643 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 |
ソースコード
/* -*- coding: utf-8 -*- * * 2037.cc: No.2037 NAND Pyramid - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 400000; /* typedef */ /* global variables */ char ss[2][MAX_N + 4]; /* subroutines */ void reduce(int n, char s0[], char s1[]) { for (int i = 0; i + 1 < n; i++) s1[i] = (s0[i] == '1' && s0[i + 1] == '1') ? '0' : '1'; s1[n - 1] = '\0'; } /* main */ int main() { int n, k; scanf("%d%d%s", &n, &k, ss[0]); int cur = 0, nxt = 1; reduce(n, ss[cur], ss[nxt]); swap(cur, nxt), n--; //puts(ss[cur]); if ((k ^ n) & 1) { reduce(n, ss[cur], ss[nxt]); swap(cur, nxt), n--; } int d = (n - k) / 2; for (int i = 0; i < k; i++) putchar(ss[cur][i + d]); putchar('\n'); return 0; }