8202022-01-18 10:43:32zsebiTáblajátékcpp11Wrong answer 25/502ms1964 KiB
#include <iostream>
//#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

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

vector < int > x;

int n,sor,i,j,a,p;

int main()
{
    cin>>n;
    sor=0;
    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==4)
        {
            for(j=x.size()-1;j>=0;--j)
            {
                if(x[j]==0)
                {
                    x[j]=1;
                for(p=j+1;p<x.size();++p)x[p]=0;
                break;
                }
            }
        }
        else if(a==3)
        {
            for(j=x.size()-1;j>=0;--j)
            {
                if(x[j]==1)
                {
                    x[j]=0;
                for(p=j+1;p<x.size();++p)x[p]=1;
                break;
                }
            }
        }
    }
    cout<<sor<<"\n";

    for(i=0;i<x.size();++i)
        cout<<x[i];
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base25/50
1Accepted0/02ms1800 KiB
2Wrong answer0/01ms1896 KiB
3Partially correct1/31ms1908 KiB
4Accepted3/31ms1912 KiB
5Partially correct1/31ms1924 KiB
6Partially correct1/31ms1912 KiB
7Partially correct1/31ms1924 KiB
8Partially correct1/31ms1928 KiB
9Partially correct1/31ms1924 KiB
10Partially correct1/31ms1932 KiB
11Accepted3/31ms1936 KiB
12Partially correct1/31ms1936 KiB
13Accepted4/41ms1956 KiB
14Accepted4/41ms1952 KiB
15Partially correct1/41ms1956 KiB
16Partially correct1/41ms1964 KiB
17Partially correct1/41ms1956 KiB