85782024-01-22 12:02:08IgnácTáblajáték 2 (70 pont)cpp17Accepted 70/703ms4004 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;
		}
		if (_0) cout << 0;
	}
}
SubtaskSumTestVerdictTimeMemory
base70/70
1Accepted0/03ms2092 KiB
2Accepted0/03ms2216 KiB
3Accepted2/23ms2432 KiB
4Accepted3/33ms2676 KiB
5Accepted3/33ms2664 KiB
6Accepted3/33ms2660 KiB
7Accepted3/33ms2688 KiB
8Accepted3/33ms2904 KiB
9Accepted3/33ms2812 KiB
10Accepted3/33ms2940 KiB
11Accepted3/33ms3188 KiB
12Accepted3/33ms3276 KiB
13Accepted3/33ms3520 KiB
14Accepted3/33ms3512 KiB
15Accepted4/43ms3648 KiB
16Accepted4/43ms3668 KiB
17Accepted4/42ms3672 KiB
18Accepted4/42ms3668 KiB
19Accepted4/42ms3676 KiB
20Accepted4/43ms3672 KiB
21Accepted4/43ms3680 KiB
22Accepted4/43ms3804 KiB
23Accepted3/33ms4004 KiB