21472022-12-25 11:33:26bzsofiaTáblajátékcpp11Wrong answer 1/503ms3608 KiB
#include <iostream>
#include <deque>

using namespace std;

int i,n,a,j;
deque <int> v;

int main()
{
    cin>>n;
    v.push_back(0);

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

        if (a==0) v.push_back(0);
        else if (a==1) v.push_back(1);
        else if (a==2) v.pop_back();
        else if (a==3)
        {
            if (v.back()==1) v.back()=0;
            else
            {
                j=v.size()-1;
                while (v[j]==0)
                {
                    v[j]=1;
                    --j;
                }
                v[j]=0;
            }
        }
        else if (a==4)
        {
            if (v.back()==0) v.back()=1;
            else
            {
                j=v.size()-1;
                while (v[j]==1)
                {
                    v[j]=0;
                    --j;
                }
                v[j]=1;
            }
        }
    }

    while (v.size()>1 && v.front()==0) v.pop_front();

    for (auto &e:v)
    {
        cout<<e;
    }

    return 0;
}
//6 0 1 4 2 1 0

//6 0 0 0 0 0 0
SubtaskSumTestVerdictTimeMemory
base1/50
1Wrong answer0/03ms1948 KiB
2Wrong answer0/02ms2112 KiB
3Wrong answer0/32ms2344 KiB
4Wrong answer0/32ms2312 KiB
5Wrong answer0/32ms2344 KiB
6Wrong answer0/32ms2556 KiB
7Wrong answer0/32ms2756 KiB
8Wrong answer0/32ms2832 KiB
9Wrong answer0/32ms3076 KiB
10Wrong answer0/32ms3032 KiB
11Wrong answer0/32ms3032 KiB
12Wrong answer0/32ms3164 KiB
13Wrong answer0/42ms3336 KiB
14Wrong answer0/42ms3404 KiB
15Wrong answer0/42ms3400 KiB
16Wrong answer0/42ms3532 KiB
17Partially correct1/42ms3608 KiB