85772024-01-22 12:00:20IgnácTáblajáték 2 (70 pont)cpp17Partially correct 68/703ms4512 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, sor = 0;
	cin >> n;
	string elem = "";
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a == 0) {
			sor++;
			elem += "0";
		}
		if (a == 1) {
			sor++;
			elem += "1";
		}
		if (a == 2) {
			sor++;
			elem += "2";
		}
		if (a == 3) {
			sor--;
			elem.pop_back();
		}
		if (a == 4) {
			int j = elem.size() - 1;
			while (elem[j] == '0') {
				elem[j] = '2';
				j--;
			}
			elem[j]--;
		}
		if (a == 5) {
			int j = elem.size() - 1;
			while (elem[j] == '2') {
				elem[j] = '0';
				j--;
			}
			elem[j]++;
		}
	}

	cout << sor << "\n";
	if (elem == "") cout << "0";
	else {
		bool _0 = true;
		for (char num : elem) {
			if (num != '0') _0 = false;
			if (!_0) cout << num;
		}
	}
}
SubtaskSumTestVerdictTimeMemory
base68/70
1Accepted0/03ms1808 KiB
2Accepted0/03ms2056 KiB
3Accepted2/23ms2272 KiB
4Accepted3/33ms2464 KiB
5Accepted3/33ms2672 KiB
6Accepted3/33ms2756 KiB
7Accepted3/33ms2784 KiB
8Accepted3/33ms2984 KiB
9Accepted3/33ms3068 KiB
10Accepted3/33ms3340 KiB
11Accepted3/33ms3288 KiB
12Accepted3/33ms3484 KiB
13Accepted3/33ms3684 KiB
14Accepted3/32ms3740 KiB
15Accepted4/43ms3876 KiB
16Accepted4/43ms4088 KiB
17Accepted4/43ms4196 KiB
18Accepted4/43ms4280 KiB
19Accepted4/43ms4164 KiB
20Accepted4/42ms4164 KiB
21Accepted4/43ms4296 KiB
22Accepted4/42ms4380 KiB
23Partially correct1/33ms4512 KiB