33132023-02-25 08:48:58horvathabelTáblajátékcpp17Time limit exceeded 34/50300ms3652 KiB
#include <bits/stdc++.h>
using namespace std;
string kettes(int x){
    
	int cnt=1; 
	while (cnt<=x){
		cnt*=2;
	}
	if (cnt!=x) cnt/=2;
	string mego="";
	if (x==0) mego+="0"; 
	while (cnt!=0){
		if (cnt<=x){
			mego+="1";
			x-=cnt;
		}
		else{
			mego+="0";
		}
		cnt/=2;
	}
	return (mego);
}
int main() {
	int n;
	cin>>n;
	pair<int, int> os={0,0};
	for (int i=0; i<n;i++){
		int k;
		cin>>k;
		if (k==0){
			os.first++;
			os.second=os.second*2;
		}
		if (k==1){
			os.first++;
			os.second=os.second*2+1;
		}	
		if (k==2){
			os.first--;
			os.second=os.second/2;
		}
		if (k==3){
			os.second--;
		}
		if (k==4){
			os.second++; 
		}
		} 
		cout<<os.first<<endl<<kettes(os.second); 

}
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2052 KiB
3Accepted3/33ms2268 KiB
4Accepted3/33ms2432 KiB
5Accepted3/33ms2512 KiB
6Time limit exceeded0/3300ms1856 KiB
7Accepted3/33ms2888 KiB
8Partially correct1/33ms2944 KiB
9Accepted3/33ms3064 KiB
10Time limit exceeded0/3298ms3156 KiB
11Accepted3/33ms3404 KiB
12Partially correct1/33ms3556 KiB
13Accepted4/43ms3652 KiB
14Partially correct1/43ms3584 KiB
15Accepted4/43ms3592 KiB
16Partially correct1/43ms3580 KiB
17Accepted4/43ms3580 KiB