64292023-11-28 21:58:40gergomiszoriTáblajátékcpp17Wrong answer 15/503ms3884 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 = 0;
    for(ll i = 0; i < k; i++)
    {
        ll l;
        cin >> l;
        if(l == 0)
        {
            ans2 = (ans2)*2 + 1;
            ans1++;
        }
        else
        if(l == 1)
        {
            ans2 = (ans2)*2 + 2;
            ans1++;
        }
        else
        if(l == 2)
        {
            ans1--;
            ans2 = (ans2/2);
        }
        else
        if(l == 3)
        {
            ans2--;
        }
        else
        if(l == 4)
        {
            ans2++;
        }
    }
    cout << ans1 << endl;
    string s = "";
    if(ans2 == 0) s += "0";
    else
    while(ans2 > 0)
    {
        if(ans2 % 2 == 0) s += "0";
        else s += "1";
        ans2 /= 2;
    }
    reverse(s.begin(), s.end());
    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
base15/50
1Wrong answer0/03ms1828 KiB
2Wrong answer0/03ms2020 KiB
3Partially correct1/33ms2228 KiB
4Partially correct1/33ms2464 KiB
5Partially correct1/33ms2704 KiB
6Partially correct1/33ms2800 KiB
7Partially correct1/33ms2856 KiB
8Partially correct1/33ms2968 KiB
9Partially correct1/32ms3056 KiB
10Partially correct1/33ms3188 KiB
11Partially correct1/33ms3520 KiB
12Partially correct1/33ms3528 KiB
13Partially correct1/43ms3604 KiB
14Partially correct1/43ms3600 KiB
15Partially correct1/43ms3552 KiB
16Partially correct1/43ms3676 KiB
17Partially correct1/43ms3884 KiB