結果

問題 No.2037 NAND Pyramid
ユーザー kotatsugamekotatsugame
提出日時 2022-08-12 21:54:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 1,143 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 6,736 KB
最終ジャッジ日時 2023-10-24 09:46:41
合計ジャッジ時間 4,329 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 25 ms
5,672 KB
testcase_08 AC 19 ms
6,184 KB
testcase_09 AC 22 ms
5,272 KB
testcase_10 AC 12 ms
5,176 KB
testcase_11 AC 26 ms
5,340 KB
testcase_12 AC 13 ms
4,428 KB
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 17 ms
5,128 KB
testcase_15 AC 21 ms
5,772 KB
testcase_16 AC 16 ms
5,140 KB
testcase_17 AC 20 ms
6,736 KB
testcase_18 AC 21 ms
6,736 KB
testcase_19 AC 32 ms
6,736 KB
testcase_20 AC 32 ms
6,736 KB
testcase_21 AC 42 ms
6,736 KB
testcase_22 AC 42 ms
6,736 KB
testcase_23 AC 43 ms
6,732 KB
testcase_24 AC 42 ms
6,732 KB
testcase_25 AC 21 ms
6,732 KB
testcase_26 AC 21 ms
6,732 KB
testcase_27 AC 31 ms
6,732 KB
testcase_28 AC 21 ms
6,732 KB
testcase_29 AC 21 ms
6,732 KB
testcase_30 AC 42 ms
6,732 KB
testcase_31 AC 33 ms
6,732 KB
testcase_32 AC 31 ms
6,732 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<deque>
using namespace std;
int N,K;
int main()
{
	cin>>N>>K;
	deque<int>Q;
	{
		string S;
		cin>>S;
		for(char c:S)Q.push_back(c-'0');
	}
	if(Q.size()>=K+2)
	{
		deque<int>nxt;
		for(int i=1;i+1<Q.size();i++)
		{
			if(Q[i]==0)nxt.push_back(0);
			else if(Q[i-1]==1||Q[i+1]==1)nxt.push_back(1);
			else nxt.push_back(0);
		}
		Q=nxt;
	}
	while(Q.size()>=K+2)
	{
		Q.pop_front();
		Q.pop_back();
	}
	if(Q.size()>K)
	{
		deque<int>nxt;
		for(int i=1;i<Q.size();i++)
		{
			if(Q[i-1]==1&&Q[i]==1)nxt.push_back(0);
			else nxt.push_back(1);
		}
		Q=nxt;
	}
	for(int i=0;i<K;i++)cout<<Q[i];
	cout<<endl;
}
0