57452023-09-15 14:55:18kukkermanTáblajátékcpp14Accepted 50/503ms3656 KiB
#include <iostream>
#include <vector>

std::vector<int> beolvas(std::istream &in) {
    int k;
    in >> k;

    std::vector<int> v(k);
    for (auto i = 0; i < k; i++) {
        in >> v[i];
    }

    return v;
}

void feldolgoz(const std::vector<int> &lepesek) {
    std::string poz{ "1" };

    size_t i;
    for (auto l : lepesek) {
        switch (l) {
        case 0: // balra le
            poz.push_back('0');
            break;

        case 1: // jobbra le
            poz.push_back('1');
            break;

        case 2: // fel
            poz.pop_back();
            break;

        case 3: // balra
            for (i = poz.size() - 1; poz[i] == '0'; i--) {
                poz[i] = '1';
            }
            poz[i] = '0';
            break;

        case 4: // jobbra
            for (i = poz.size() - 1; poz[i] == '1'; i--) {
                poz[i] = '0';
            }
            poz[i] = '1';
            break;
        }
    }

    const auto n = poz.size();
    std::cout << n - 1 << '\n';

    i = 1u;
    for (i = 1u; i < n && poz[i] == '0'; i++) {}
    if (i < n) {
        for (; i < n; i++) {
            std::cout << poz[i];
        }
    } else {
        std::cout << '0';
    }
    std::cout << std::endl;
}

int main() {
    const auto v = beolvas(std::cin);
    feldolgoz(v);

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2008 KiB
3Accepted3/32ms2152 KiB
4Accepted3/33ms2352 KiB
5Accepted3/32ms2444 KiB
6Accepted3/33ms2660 KiB
7Accepted3/32ms2744 KiB
8Accepted3/32ms2756 KiB
9Accepted3/32ms2764 KiB
10Accepted3/33ms2896 KiB
11Accepted3/32ms3108 KiB
12Accepted3/32ms3196 KiB
13Accepted4/42ms3332 KiB
14Accepted4/43ms3548 KiB
15Accepted4/42ms3632 KiB
16Accepted4/42ms3640 KiB
17Accepted4/43ms3656 KiB