64322023-11-28 22:33:18gergomiszoriTáblajátékcpp17Wrong answer 36/503ms3928 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl "\n"
#define pll pair<ll,ll>
#define fs first
#define sc second

void solve()
{
    ll k;
    cin >> k;
    ll ans1 = 0; string ans2 = "0";
    for(ll i = 0; i < k; i++)
    {
        ll l;
        cin >> l;
        if(l == 0)
        {
            ans2 += "0";
            ans1++;
        }
        else
        if(l == 1)
        {
            ans2 += "1";
            ans1++;
        }
        else
        if(l == 2)
        {
            ans2.pop_back();
            ans1--;
        }
        else
        if(l == 3)
        {
            if(ans2[ans2.size()-1] == '1') ans2[ans2.size()-1] = '0';
            else
            {
                ll index = 1;
                while(ans2[ans2.size()-index] != '1')
                {
                    ans2[ans2.size()-index] = '1';
                    index++;
                }
                ans2[ans2.size()-index] = '0';
            }
        }
        else
        if(l == 4)
        {
            if(ans2[ans2.size()-1] == '0') ans2[ans2.size()-1] = '1';
            else
            {
                ll index = 1;
                while(ans2[ans2.size()-index] != '0') index++;
                ans2[ans2.size()-index] = '1';
            }
        }
    }
    while(ans2[0] == '0') ans2.erase(ans2.begin());
    if(ans2.size() == 0) ans2 = "0";
    cout << ans1 << endl;
    cout << ans2 << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base36/50
1Accepted0/03ms1700 KiB
2Wrong answer0/03ms1864 KiB
3Accepted3/33ms2096 KiB
4Accepted3/33ms2292 KiB
5Accepted3/33ms2496 KiB
6Accepted3/33ms2708 KiB
7Accepted3/32ms2792 KiB
8Accepted3/33ms2924 KiB
9Accepted3/32ms2988 KiB
10Accepted3/33ms3212 KiB
11Partially correct1/33ms3424 KiB
12Accepted3/33ms3636 KiB
13Partially correct1/43ms3724 KiB
14Partially correct1/43ms3828 KiB
15Partially correct1/43ms3724 KiB
16Partially correct1/43ms3776 KiB
17Accepted4/43ms3928 KiB