85762024-01-22 11:54:03IgnácTáblajáték 2 (70 pont)cpp17Partially correct 42/703ms4576 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 cout << elem;
}
SubtaskSumTestVerdictTimeMemory
base42/70
1Accepted0/03ms1820 KiB
2Accepted0/03ms2052 KiB
3Partially correct1/23ms2268 KiB
4Partially correct1/33ms2480 KiB
5Partially correct1/33ms2724 KiB
6Partially correct1/33ms2936 KiB
7Accepted3/33ms3116 KiB
8Accepted3/33ms3236 KiB
9Accepted3/33ms3348 KiB
10Accepted3/33ms3176 KiB
11Partially correct1/33ms3276 KiB
12Partially correct1/33ms3356 KiB
13Accepted3/33ms3612 KiB
14Accepted3/33ms3848 KiB
15Accepted4/43ms3976 KiB
16Accepted4/43ms4084 KiB
17Partially correct1/43ms4120 KiB
18Partially correct1/43ms4100 KiB
19Partially correct1/43ms4212 KiB
20Partially correct1/43ms4220 KiB
21Partially correct1/43ms4336 KiB
22Accepted4/42ms4420 KiB
23Partially correct1/33ms4576 KiB