247082026-02-14 13:56:10PKBTáblajáték 2 (70 pont)cpp14Partially correct 51/701ms508 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

string nulla_nelkul(long long x) {
    if (x == 0) return "0";
    string s;
    while (x > 0) {
        s.push_back('0' + (x % 3));
        x /= 3;
    }
    reverse(s.begin(), s.end());
    return s;
}

int main() {
    int K;
    cin >> K;

    long long sor = 0;   
    long long i = 0;

    for (int k = 0; k < K; k++) {
        int step;
        cin >> step;

        if (step == 0) { // balra le
            i = 3 * i;
            sor++;
        }
        else if (step == 1) { // középre le
            i = 3 * i + 1;
            sor++;
        }
        else if (step == 2) {// jobbra le
            i = 3 * i + 2;
            sor++;
        }
        else if (step == 3) {// fel
            i /= 3;
            sor--;
        }
        else if (step == 4) { // balra
            i--;
        }
        else if (step == 5) {// jobbra
            i++;
        }
    }

    cout << sor << "\n";
    cout << nulla_nelkul(i) << "\n";
}
SubtaskSumTestVerdictTimeMemory
base51/70
1Accepted0/01ms316 KiB
2Accepted0/01ms508 KiB
3Accepted2/21ms500 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Partially correct1/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Partially correct1/31ms316 KiB
13Accepted3/31ms316 KiB
14Accepted3/31ms316 KiB
15Accepted4/41ms376 KiB
16Partially correct1/41ms316 KiB
17Accepted4/41ms316 KiB
18Accepted4/41ms316 KiB
19Partially correct1/41ms316 KiB
20Partially correct1/41ms316 KiB
21Partially correct1/41ms316 KiB
22Partially correct1/41ms316 KiB
23Accepted3/31ms316 KiB