7752022-01-10 16:00:42Kevinke12Táblajátékcpp14Accepted 50/502ms1960 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

unsigned long long N, aktO=0, l, ans1=0;
vector<char> almafa;
int main()
{
    cin >> N;
    almafa.push_back('0');
    for(int i = 0; i < N; i++)
    {
        cin >> l;
        if((l==0) ||(l==1)) ans1++;
        if(l==2) ans1--;

        if(l==0)
        {
            almafa.push_back('0');
        }
        if(l==1)
        {
            almafa.push_back('1');
        }
        if(l==2) //fel
        {
            almafa.pop_back();
        }
        if(l==3)
        {
            for(int i = almafa.size()-1; i >= 0; i--)
            {
                if(almafa[i]=='0') almafa[i]='1';
                else
                {
                    almafa[i] = '0'; break;
                }
            }
        }
        if(l==4)
        {
            for(int i = almafa.size()-1; i >= 0; i--)
            {
                if(almafa[i]=='1') almafa[i]='0';
                else
                {
                    almafa[i] = '1'; break;
                }
            }
        }

        //cout << ans1 << " " << aktO << "\n";

    }
    cout << ans1 << "\n";
    reverse(almafa.begin(), almafa.end());
    while((almafa[almafa.size()-1]=='0'))
    {
        almafa.pop_back();
    }
    reverse(almafa.begin(), almafa.end());
    for(char c:almafa)
        cout << c;
    if(almafa.size()==0)
        cout << "0";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1820 KiB
2Accepted0/01ms1836 KiB
3Accepted3/31ms1900 KiB
4Accepted3/31ms1916 KiB
5Accepted3/32ms1912 KiB
6Accepted3/32ms1912 KiB
7Accepted3/31ms1924 KiB
8Accepted3/31ms1924 KiB
9Accepted3/31ms1928 KiB
10Accepted3/31ms1928 KiB
11Accepted3/31ms1936 KiB
12Accepted3/31ms1944 KiB
13Accepted4/41ms1944 KiB
14Accepted4/42ms1944 KiB
15Accepted4/41ms1952 KiB
16Accepted4/41ms1956 KiB
17Accepted4/41ms1960 KiB