16192022-11-29 17:18:29kovacs.peter.18fTáblajátékcpp11Time limit exceeded 30/50300ms3468 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 = (index - 1) / 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
base30/50
1Accepted0/03ms1824 KiB
2Accepted0/02ms2060 KiB
3Accepted3/32ms2264 KiB
4Accepted3/32ms2464 KiB
5Accepted3/32ms2508 KiB
6Time limit exceeded0/3270ms2472 KiB
7Accepted3/32ms2744 KiB
8Time limit exceeded0/3300ms2832 KiB
9Accepted3/32ms3036 KiB
10Time limit exceeded0/3268ms3116 KiB
11Accepted3/32ms3212 KiB
12Wrong answer0/32ms3220 KiB
13Accepted4/42ms3216 KiB
14Time limit exceeded0/4287ms3468 KiB
15Accepted4/42ms3452 KiB
16Wrong answer0/42ms3352 KiB
17Accepted4/42ms3460 KiB