18072022-12-03 20:18:54kdbTáblajátékcpp11Partially correct 47/503ms4104 KiB
#include <iostream>
#include <vector>
#include <map>
#include <deque>
using namespace std;
#define ll long long

ostream& operator<<(ostream& os, vector<int>& input)
{
    for (auto i : input)
    {
        os << i << " ";
    }
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    deque<int>q;
    cin >> n;
    while (n--)
    {
        int a;
        cin >> a;
        if (a == 0) q.push_back(0);
        else if (a == 1) q.push_back(1);
        else if (a == 2) q.pop_back();
        else if (a == 3)
        {
            int i = q.size() - 1;
            while (q[i]==0)
            {
                q[i] = 1;
                i--;
            }
            q[i] = 0;
        }
        else if (a == 4)
        {
            int i = q.size() - 1;
            while (q[i]==1)
            {
                q[i] = 0;
                i--;
            }
            q[i] = 1;
        }
    }
    cout << q.size() << endl;
    while (q.size() > 1 && q[0] == 0) q.pop_front();
    while (q.size()>0)
    {
        cout << q.front();
        q.pop_front();
    }
    return 0;
}
/*
6
0 1 4 2 1 0
-3
-110

6
0 0 0 0 0 0
-6
-0
*/
SubtaskSumTestVerdictTimeMemory
base47/50
1Accepted0/03ms1704 KiB
2Accepted0/02ms1868 KiB
3Accepted3/32ms2064 KiB
4Accepted3/32ms2272 KiB
5Accepted3/32ms2500 KiB
6Accepted3/32ms2700 KiB
7Accepted3/32ms2912 KiB
8Accepted3/32ms3108 KiB
9Accepted3/32ms3168 KiB
10Accepted3/32ms3260 KiB
11Accepted3/32ms3392 KiB
12Accepted3/32ms3592 KiB
13Accepted4/42ms3700 KiB
14Accepted4/42ms3884 KiB
15Accepted4/42ms3956 KiB
16Accepted4/42ms4104 KiB
17Partially correct1/42ms4088 KiB