51382023-04-20 02:39:44tomi7Táblajáték 2 (70 pont)cpp11Wrong answer 26/703ms4144 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);
	unsigned long long y=31381059609;
	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/03ms1960 KiB
2Wrong answer0/03ms2160 KiB
3Accepted2/23ms2376 KiB
4Partially correct1/33ms2596 KiB
5Accepted3/33ms2644 KiB
6Partially correct1/33ms2736 KiB
7Accepted3/33ms2952 KiB
8Wrong answer0/32ms3032 KiB
9Partially correct1/33ms3304 KiB
10Partially correct1/33ms3492 KiB
11Accepted3/33ms3424 KiB
12Partially correct1/33ms3548 KiB
13Partially correct1/33ms3632 KiB
14Partially correct1/33ms3700 KiB
15Partially correct1/43ms3836 KiB
16Partially correct1/43ms3764 KiB
17Partially correct1/43ms4052 KiB
18Partially correct1/43ms3972 KiB
19Partially correct1/43ms4036 KiB
20Partially correct1/43ms4044 KiB
21Partially correct1/42ms4048 KiB
22Partially correct1/43ms4144 KiB
23Wrong answer0/32ms4040 KiB