38932023-03-03 18:44:31horvathabelTáblajátékcpp17Wrong answer 25/503ms3828 KiB
#include <iostream>
#include <vector> 
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> mego;
	int o=0;
	for (int i=0;i<n;i++){
		int x;
		cin>>x;
		if (x==0){
			o++;
			mego.push_back(0);
		}
		if (x==1){
			o++;
			mego.push_back(1);
		}
		if (x==2){
			o--;
			mego.erase(mego.begin()+mego.size()-1);
		}
		if (x==3){
			int cnt=0;
			for (int i=mego.size()-1;i>=0;i--){
				if (mego[i]==1){
					cnt=i;
					mego[i]=0;
					break;
				}
			}
			if (cnt+1!=mego.size()){
				for (int i=cnt+1; i<mego.size();i++){
					mego[i]=1;
			}
			}
		}
		if (x==4){
			int cnt=0;
			for (int i=mego.size()-1;i>=0;i--){
				if (mego[i]==0){
					cnt=i;
					mego[i]=1;
					break;
				}
			}
			
			if (cnt!=mego.size()){
				for (int i=cnt+1; i<mego.size();i++){
					mego[i]=0;
			}
			}
		}
		
 	}
	cout<<o<<endl;
	for (auto x:mego) cout<<x; 
	
}
SubtaskSumTestVerdictTimeMemory
base25/50
1Accepted0/03ms1812 KiB
2Wrong answer0/03ms2052 KiB
3Partially correct1/32ms2300 KiB
4Accepted3/32ms2352 KiB
5Partially correct1/33ms2592 KiB
6Partially correct1/33ms2804 KiB
7Partially correct1/33ms2976 KiB
8Partially correct1/33ms3184 KiB
9Partially correct1/32ms3300 KiB
10Partially correct1/33ms3432 KiB
11Accepted3/32ms3392 KiB
12Partially correct1/32ms3360 KiB
13Accepted4/42ms3480 KiB
14Accepted4/42ms3492 KiB
15Partially correct1/42ms3612 KiB
16Partially correct1/43ms3616 KiB
17Partially correct1/42ms3828 KiB