51372023-04-20 02:37:07tomi7Táblajáték 2 (70 pont)cpp11Wrong answer 26/703ms4324 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
int harmasszamrendszerbe(int x, long long y, bool b){
	if(x/y>0){
		cout<<x/y;
		x=x%y;
		b=true;
	}else if(b){
		cout<<0;
	}
	if(y/3==0){
		return 0;
	}else{
		return harmasszamrendszerbe(x, y/3, b);
	}
}

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	long long y=43046721;
	pair<int, int> valasz;
	valasz.first=0;
	valasz.second=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			valasz.first++;
			valasz.second*=3;
		}else if(a[i]==1){
			valasz.first++;
			valasz.second=valasz.second*3+1;
		}else if(a[i]==2){
			valasz.first++;
			valasz.second=valasz.second*3+2;
		}else if(a[i]==3){
			valasz.first--;
			valasz.second=valasz.second/3;
		}else if(a[i]==4){
			valasz.second--;
		}else if(a[i]==5){
			valasz.second++;
		}
	}
	bool b=false;
	cout<<valasz.first<<'\n';
	if(valasz.second==0){
		cout<<0<<'\n';
	}else{
		harmasszamrendszerbe(valasz.second, y, b);
	}
}
SubtaskSumTestVerdictTimeMemory
base26/70
1Accepted0/03ms1812 KiB
2Wrong answer0/03ms2004 KiB
3Accepted2/23ms2248 KiB
4Partially correct1/32ms2332 KiB
5Accepted3/32ms2464 KiB
6Partially correct1/33ms2668 KiB
7Accepted3/33ms2876 KiB
8Wrong answer0/33ms2936 KiB
9Partially correct1/32ms3076 KiB
10Partially correct1/32ms3012 KiB
11Accepted3/33ms3264 KiB
12Partially correct1/32ms3336 KiB
13Partially correct1/33ms3584 KiB
14Partially correct1/33ms3796 KiB
15Partially correct1/43ms3764 KiB
16Partially correct1/42ms3884 KiB
17Partially correct1/43ms4052 KiB
18Partially correct1/42ms4108 KiB
19Partially correct1/42ms4112 KiB
20Partially correct1/43ms4244 KiB
21Partially correct1/42ms4324 KiB
22Partially correct1/42ms4320 KiB
23Wrong answer0/32ms4284 KiB