33162023-02-25 08:55:46horvathabelTáblajátékcpp17Partially correct 38/503ms4144 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long; 
string kettes(int x){
	string mego="";
    
	if (x==0) mego+="0";
	while (x>0){
		mego+=to_string(x%2);
		x=x/2;
	}
	reverse(mego.begin(), mego.end());
	return (mego);
}
int main() {
	int n;
	cin>>n;
	pair<ll, ll> 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
base38/50
1Accepted0/03ms1716 KiB
2Accepted0/03ms1936 KiB
3Accepted3/33ms2184 KiB
4Accepted3/33ms2352 KiB
5Accepted3/33ms2440 KiB
6Partially correct1/33ms2684 KiB
7Accepted3/32ms2728 KiB
8Accepted3/32ms2732 KiB
9Accepted3/33ms2856 KiB
10Partially correct1/33ms3064 KiB
11Accepted3/33ms3420 KiB
12Partially correct1/33ms3396 KiB
13Accepted4/43ms3596 KiB
14Partially correct1/43ms3804 KiB
15Accepted4/43ms4016 KiB
16Partially correct1/43ms4032 KiB
17Accepted4/43ms4144 KiB