64262023-11-28 21:48:13gergomiszoriTáblajátékcpp17Wrong answer 19/503ms4244 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, ans2 = 1;
    for(ll i = 0; i < k; i++)
    {
        ll l;
        cin >> l;
        if(l == 0)
        {
            ans2 = (ans2-1)*2 + 1;
            ans1++;
        }
        else
        if(l == 1)
        {
            ans2 = (ans2-1)*2 + 2;
            ans1++;
        }
        else
        if(l == 2)
        {
            ans1--;
            ans2 = (ans2/2)+1;
        }
        else
        if(l == 3)
        {
            ans2--;
        }
        else
        if(l == 4)
        {
            ans2++;
        }
    }
    ans2--;
    cout << ans1 << endl;
    string s = "";
    while(true)
    {
        if(ans2 % 2 == 0) s += "0";
        else s += "1";
        if(ans2 == 0) break;
        ans2 /= 2;
    }
    cout << s << 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
base19/50
1Wrong answer0/03ms1828 KiB
2Wrong answer0/03ms2052 KiB
3Accepted3/33ms2268 KiB
4Partially correct1/33ms2440 KiB
5Partially correct1/33ms2660 KiB
6Partially correct1/33ms2868 KiB
7Partially correct1/33ms2956 KiB
8Partially correct1/33ms3076 KiB
9Accepted3/32ms3160 KiB
10Partially correct1/33ms3292 KiB
11Partially correct1/33ms3500 KiB
12Partially correct1/32ms3588 KiB
13Partially correct1/42ms3588 KiB
14Partially correct1/43ms3808 KiB
15Partially correct1/43ms3924 KiB
16Partially correct1/43ms4152 KiB
17Partially correct1/43ms4244 KiB