結果
| 問題 |
No.2037 NAND Pyramid
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2024-07-12 00:49:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 1,474 bytes |
| コンパイル時間 | 2,122 ms |
| コンパイル使用メモリ | 196,728 KB |
| 最終ジャッジ日時 | 2025-02-22 03:03:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N,K;cin>>N>>K;
string S;cin>>S;
if(N<=10){
while(si(S)>=1){
if(si(S)==K){
cout<<S<<endl;
return 0;
}
string T;
for(int i=0;i+1<si(S);i++){
if(S[i]=='1'&&S[i+1]=='1') T+='0';
else T+='1';
}
S=T;
}
}
string A,B;
for(int q=0;q<4;q++){
if(si(S)==K){
cout<<S<<endl;
return 0;
}
string T;
for(int i=0;i+1<si(S);i++){
if(S[i]=='1'&&S[i+1]=='1') T+='0';
else T+='1';
}
S=T;
if(q==2) A=S;
if(q==3) B=S;
}
if((si(A)-K)%2==0){
for(int x=(si(A)-K)/2;x<si(A)-(si(A)-K)/2;x++) cout<<A[x];
cout<<endl;
}else{
for(int x=(si(B)-K)/2;x<si(B)-(si(B)-K)/2;x++) cout<<B[x];
cout<<endl;
}
}
Rubikun