結果
| 問題 |
No.2037 NAND Pyramid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-12 22:45:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 697 bytes |
| コンパイル時間 | 1,555 ms |
| コンパイル使用メモリ | 168,348 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-23 03:25:09 |
| 合計ジャッジ時間 | 3,143 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k; cin >> n >> k;
string s; cin >> s;
int eve = n - (n - k) / 2 * 2;
string ans;
for (int i = 0; i < eve; i++) {
int ind = i + (n - eve) / 2;
if (s[ind] == '1' && (i > 0 && s[ind - 1] == '1' || i + 1 < n && s[ind + 1] == '1')) {
ans.push_back('1');
} else {
ans.push_back('0');
}
}
if (eve == n) {
ans = s;
}
if (k != eve) {
for (int i = 0; i < k; i++) {
ans[i] = (ans[i] & ans[i + 1]) ^ 1;
}
ans.pop_back();
}
cout << ans;
}