252272026-02-18 16:44:51Rudika11Táblajáték 2 (70 pont)cpp17Partially correct 51/702ms508 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> steps(n);
    for(int i = 0; i < n; i++) cin >> steps[i];
    long long row = 0;
    long long index = 0;
    for(int i = 0; i < n; i++) {
        int step = steps[i];
        if(step == 0 || step == 1 || step == 2) {
            index = index * 3 + step;
            row++;
        }
        else if(step == 3) {
            index /= 3;
            row--;
        }
        else if(step == 4) {
            index--;
        }
        else if(step == 5) {
            index++;
        }
    }
    cout << row << "\n";
    if(index == 0) cout << 0;
    else{
        string s = "";
        while(index > 0) {
            s = char('0' + (index % 3)) + s;
            index /= 3;
        }
        cout << s;
    }
}
SubtaskSumTestVerdictTimeMemory
base51/70
1Accepted0/01ms508 KiB
2Accepted0/01ms508 KiB
3Accepted2/21ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Partially correct1/31ms316 KiB
7Accepted3/31ms508 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms500 KiB
11Accepted3/31ms508 KiB
12Partially correct1/31ms392 KiB
13Accepted3/31ms316 KiB
14Accepted3/31ms316 KiB
15Accepted4/41ms508 KiB
16Partially correct1/41ms316 KiB
17Accepted4/42ms316 KiB
18Accepted4/41ms316 KiB
19Partially correct1/41ms316 KiB
20Partially correct1/41ms316 KiB
21Partially correct1/41ms500 KiB
22Partially correct1/41ms400 KiB
23Accepted3/31ms316 KiB