結果
問題 | No.2037 NAND Pyramid |
ユーザー |
|
提出日時 | 2022-08-13 20:27:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 2,132 ms |
コンパイル使用メモリ | 194,068 KB |
最終ジャッジ日時 | 2025-01-30 22:20:01 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 |
ソースコード
#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int N,K;string S;cin>>N>>K>>S;string S2="",S3="";for(int i=0;i<N-1;i++){S2.push_back(S[i]=='1'&&S[i+1]=='1'?'0':'1');}for(int i=0;i<N-2;i++){S3.push_back(S2[i]=='1'&&S2[i+1]=='1'?'0':'1');}string ret="";if((N-K)%2){int t=(N-K-1)/2;for(int i=0;i<K;i++){ret+=S2[i+t];}}else{int t=(N-K-2)/2;for(int i=0;i<K;i++){ret+=S3[i+t];}}cout<<ret<<'\n';}