結果
| 問題 |
No.2037 NAND Pyramid
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-08-12 21:43:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 755 bytes |
| コンパイル時間 | 4,358 ms |
| コンパイル使用メモリ | 256,364 KB |
| 最終ジャッジ日時 | 2025-01-30 20:57:03 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 39 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
deque<char> get(deque<char> x){
deque<char> ret;
rep(i,x.size()-1){
int a = x[i] - '0';
int b = x[i+1] - '0';
a &= b;
a ^= 1;
ret.push_back('0' + a);
}
return ret;
}
int main() {
int N,K;
cin>>N>>K;
string s;
cin>>s;
deque<char> ans;
rep(i,s.size()){
ans.push_back(s[i]);
}
int cur = N;
cur--;
ans = get(ans);
while(cur!=K){
if(cur-2 >= K){
ans.pop_front();
ans.pop_back();
cur -= 2;
}
else{
ans = get(ans);
cur--;
}
}
rep(i,K){
cout<<ans[i];
}
cout<<endl;
return 0;
}
沙耶花