16182022-11-29 17:02:44kovacs.peter.18fTáblajátékcpp11Wrong answer 21/50300ms4068 KiB
#include <iostream>
#include <stack>

using namespace std;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int K;
    cin >> K;
    long long index = 0;
    while (K--) {
        int L;
        cin >> L;
        switch (L) {
            case 0: index = 2 * index + 1; break;
            case 1: index = 2 * index + 2; break;
            case 2: index /= 2; break;
            case 3: --index; break;
            case 4: ++index; break;
        }
    }
    int row = 0, current = 0;
    while (2 * current + 1 <= index) {
        current = 2 * current + 1;
        ++row;
    }
    cout << row << '\n';
    index -= current;
    if (index == 0) {
        cout << "0\n";
        return 0;
    }
    stack<int> digitS;
    while (index) {
        digitS.push(index % 2);
        index /= 2;
    }
    while (!digitS.empty()) {
        cout << digitS.top();
        digitS.pop();
    }
    cout << '\n';
}
SubtaskSumTestVerdictTimeMemory
base21/50
1Accepted0/03ms1824 KiB
2Wrong answer0/02ms2060 KiB
3Accepted3/32ms2416 KiB
4Accepted3/32ms2584 KiB
5Accepted3/32ms2792 KiB
6Time limit exceeded0/3300ms2056 KiB
7Partially correct1/32ms3016 KiB
8Time limit exceeded0/3300ms2280 KiB
9Accepted3/32ms3324 KiB
10Time limit exceeded0/3300ms3424 KiB
11Accepted3/32ms3684 KiB
12Wrong answer0/32ms3692 KiB
13Accepted4/42ms3800 KiB
14Time limit exceeded0/4298ms3200 KiB
15Partially correct1/42ms4004 KiB
16Time limit exceeded0/4300ms4044 KiB
17Wrong answer0/42ms4068 KiB