195192025-12-12 11:48:46gkataA szomjas pincércpp17Wrong answer 0/10026ms820 KiB
// tablajatek.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#define ll long long

using namespace std;

ll sz = 0, n, i, a, j;
deque <ll>x;

int main()
{
    cin >> n;
    for (i = 1; i <= n; ++i)
    {
        cin >> a;

        if (a == 0)
        {
            x.push_back(0);
            sz = sz + 1;
        }

        if (a == 1)
        {
            x.push_back(1);
            sz = sz + 1;
        }

        if (a == 2)
        {
            x.pop_back();
            --sz;
        }

        if (a == 3)
        {
            j = x.size() - 1;
            while (j >= 0 && x[j]==0)
            {
                x[j] = 1;
                --j;
            }
            if (j >= 0) x[j] = 0;
        }

        if (a == 4)
        {
            j = x.size() - 1;
            while (j >= 0 && x[j] == 1)
            {
                x[j] = 0;
                --j;
            }
            if (j >= 0) x[j] = 1;
        }
    }

    cout << sz << " " << endl;

    if(x.empty()) cout << "0";
    else for (auto& e : x) cout << e;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer1ms316 KiB
2Wrong answer1ms508 KiB
subtask20/20
3Wrong answer1ms316 KiB
4Wrong answer1ms316 KiB
5Runtime error1ms412 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms316 KiB
subtask30/30
8Wrong answer1ms316 KiB
9Wrong answer1ms316 KiB
10Runtime error1ms412 KiB
11Wrong answer1ms316 KiB
12Wrong answer1ms316 KiB
13Wrong answer1ms508 KiB
14Runtime error1ms404 KiB
15Runtime error2ms564 KiB
16Wrong answer1ms316 KiB
17Runtime error1ms316 KiB
18Wrong answer1ms316 KiB
subtask40/50
19Wrong answer1ms316 KiB
20Wrong answer1ms316 KiB
21Wrong answer1ms316 KiB
22Wrong answer1ms316 KiB
23Runtime error1ms412 KiB
24Wrong answer1ms316 KiB
25Wrong answer1ms316 KiB
26Wrong answer1ms508 KiB
27Runtime error1ms404 KiB
28Runtime error2ms564 KiB
29Wrong answer1ms316 KiB
30Runtime error1ms316 KiB
31Wrong answer1ms316 KiB
32Wrong answer2ms316 KiB
33Runtime error2ms316 KiB
34Runtime error1ms316 KiB
35Wrong answer12ms416 KiB
36Runtime error12ms644 KiB
37Wrong answer7ms508 KiB
38Wrong answer26ms820 KiB