144672025-01-10 22:18:22999Táblajátékcpp17Wrong answer 34/501ms548 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include <string>
using namespace std;
#define int long long

signed main() {
	int k;cin>>k;
	int s=0;
	string h="0";
	for(int i = 0;i<k;i++){
		int a;cin>>a;
		if(a==0){
			s++;
			if(h!="00"){
				h+="0";
			}
		}
		else if(a==1){
			s++;
			if(h!="00"){
				h+="1";
			}
			else{
				h="01";
			}
		}
		else if(a==2){
			s--;
			if(h!="0"){
				h='0'+h.substr(0,h.size()-1);
			}
		}
		else if(a==3){
			int i=h.size()-1;
			while(h[i]=='0'&&i>0){
				h[i]='1';
				i--;
			}
			h[i]='0';
		}
		else if(a==4){
			int i=h.size()-1;
			while(h[i]=='1'&&i>0){
				h[i]='0';
				i--;
			}
			h[i]='1';
		}
	}
	cout<<s<<endl<<h.substr(1,h.size()-1);
}
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms500 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Partially correct1/31ms500 KiB
8Partially correct1/31ms316 KiB
9Partially correct1/31ms316 KiB
10Partially correct1/31ms316 KiB
11Accepted3/31ms316 KiB
12Partially correct1/31ms316 KiB
13Accepted4/41ms316 KiB
14Accepted4/41ms316 KiB
15Partially correct1/41ms316 KiB
16Partially correct1/41ms316 KiB
17Accepted4/41ms548 KiB