102222024-03-29 16:37:54VargusTáblajátékcpp17Partially correct 38/503ms3740 KiB
#include <iostream>
#include <cmath>
#include <queue>
#define ll long long

using namespace std;

void szam(ll elem)
{
    if (elem == 0)
        return;
    szam(elem / 2);
    cout << elem % 2;
}

int main()
{
    ll n, sor = 0, elem = 0;
    cin >> n;
    for (ll i = 1; i <= n; ++i)
    {
        ll a;
        cin >> a;
        if (a == 0)
        {
            if (elem == 0)
            {
                ++sor;
                continue;
            }
            elem = 2 * elem;
            ++sor;
        }
        else if (a == 1)
        {
            if (elem == 0)
            {
                ++elem;
                ++sor;
                continue;
            }
            elem = 2 * elem + 1;
            ++sor;
        }
        else if (a == 2)
        {
            --sor;
            elem /= 2;
        }
        else if (a == 3)
        {
            --elem;
        }
        else if (a == 4)
        {
            ++elem;
        }
    }

    cout << sor << endl;
    if (elem == 0)
    {
        cout << "0";
        return 0;
    }
    szam(elem);

    return 0;
}
/*
6
0 0 0 0 0 0
*/
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms2116 KiB
3Accepted3/33ms2332 KiB
4Accepted3/33ms2416 KiB
5Accepted3/33ms2504 KiB
6Partially correct1/33ms2724 KiB
7Accepted3/33ms2944 KiB
8Accepted3/33ms3188 KiB
9Accepted3/33ms3240 KiB
10Partially correct1/33ms3360 KiB
11Accepted3/33ms3360 KiB
12Partially correct1/33ms3368 KiB
13Accepted4/43ms3608 KiB
14Partially correct1/43ms3604 KiB
15Accepted4/43ms3692 KiB
16Partially correct1/43ms3708 KiB
17Accepted4/43ms3740 KiB