64282023-11-28 21:51:37gergomiszoriTáblajátékcpp17Wrong answer 28/503ms3488 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 = "";
    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
base28/50
1Accepted0/03ms1824 KiB
2Wrong answer0/03ms2024 KiB
3Accepted3/33ms2104 KiB
4Accepted3/33ms2232 KiB
5Accepted3/33ms2200 KiB
6Partially correct1/33ms2428 KiB
7Partially correct1/33ms2644 KiB
8Partially correct1/33ms2756 KiB
9Accepted3/33ms2840 KiB
10Partially correct1/33ms3068 KiB
11Accepted3/33ms3048 KiB
12Partially correct1/33ms3280 KiB
13Accepted4/43ms3276 KiB
14Partially correct1/43ms3404 KiB
15Partially correct1/43ms3488 KiB
16Partially correct1/43ms3488 KiB
17Partially correct1/43ms3484 KiB