8212022-01-18 10:56:44Halasz EszterTáblajátékcpp11Accepted 50/502ms1968 KiB
#include <iostream>
//#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("tablajatek.in");
//ofstream cout("tablajatek.out");

vector<int>x;

int i,j,n,a,k,sor=0;


int main()
{
    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>a;
        if(a==0)
        {
            sor++;
            x.push_back(0);
        }
        else if(a==1)
        {
            sor++;
            x.push_back(1);
        }
        else if(a==2)
        {
            sor--;
            x.pop_back();
        }
        else if(a==3)
        {
            j=x.size()-1;
            while(j>=0)
            {
                if(x[j]==1)
                {
                    x[j]=0;
                    for(k=j+1;k<x.size();++k) x[k]=1;
                    break;
                }
                j--;
            }
        }
        else if(a==4)
        {
            j=x.size()-1;
            while(j>=0)
            {
                if(x[j]==0)
                {
                    x[j]=1;
                    for(k=j+1;k<x.size();++k) x[k]=0;
                    break;
                }
                j--;
            }
        }
    }
    cout<<sor<<"\n";
    bool f=false;
    for(i=0;i<x.size();++i)
    {
        if(x[i]==1)
        {
            for(j=i;j<x.size();++j)
            {
                cout<<x[j];
                f=true;
            }
            break;
        }
    }
    if(f==false) cout<<0;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1836 KiB
2Accepted0/01ms1844 KiB
3Accepted3/31ms1912 KiB
4Accepted3/31ms1912 KiB
5Accepted3/31ms1920 KiB
6Accepted3/31ms1924 KiB
7Accepted3/31ms1924 KiB
8Accepted3/31ms1928 KiB
9Accepted3/31ms1936 KiB
10Accepted3/31ms1940 KiB
11Accepted3/31ms1940 KiB
12Accepted3/31ms1944 KiB
13Accepted4/41ms1948 KiB
14Accepted4/41ms1948 KiB
15Accepted4/41ms1956 KiB
16Accepted4/41ms1960 KiB
17Accepted4/41ms1968 KiB