157062025-02-21 21:54:33TakacsAndrasTáblajáték 2 (70 pont)cpp17Runtime error 44/7035ms32000 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
string h(int x) {
    if (x == 1) return "1";
    if (x == 2) return "2";
    return h(x/3)+to_string(x%3);
}
signed main() {
    int k; cin >> k;
    long long s = 0, e = 0;
    for (int i = 0; i < k; i++) {
        int x; cin >> x;
        if (x == 0) {
            s++;
            e *= 3;
        }
        if (x == 1) {
            s++;
            e = e*3+1;
        }
        if (x == 2) {
            s++;
            e = e*3+2;
        }
        if (x == 3) {
            s--;
            e /= 3;
        }
        if (x == 4) e--;
        if (x == 5) e++;
    }
    cout << s << '\n' << h(e);
}
SubtaskSumTestVerdictTimeMemory
base44/70
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms548 KiB
6Runtime error0/329ms32000 KiB
7Accepted3/31ms500 KiB
8Accepted3/31ms536 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Partially correct1/31ms316 KiB
13Accepted3/31ms508 KiB
14Accepted3/31ms316 KiB
15Accepted4/41ms316 KiB
16Partially correct1/41ms320 KiB
17Accepted4/41ms316 KiB
18Accepted4/41ms316 KiB
19Runtime error0/435ms32000 KiB
20Runtime error0/435ms32000 KiB
21Partially correct1/41ms316 KiB
22Runtime error0/429ms32000 KiB
23Runtime error0/335ms32000 KiB