63952023-11-27 11:12:21MrChipserTáblajátékcpp11Partially correct 38/503ms3792 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long x = 1;
    long long y = 1;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(a==0)
        {
            y++;
            x=x*2-1;
        }
        if(a==1)
        {
            y++;
            x=x*2;
        }
        if(a==2)
        {
            y--;
            if(x%2==0)
                x=x/2;
            else
                x=(x+1)/2;
        }
        if(a==3)
            x--;
        if(a==4)
            x++;
        //cout << x << " " << y << endl;
    }
    cout << y-1 << endl;
    vector<int>binary;
    x--;
    if(x==0)
    {
        cout << 0;
    }
    else
    {
    while(x!=0)
    {
        binary.insert(binary.begin(),x%2);
        x/=2;
    }
    for(int i = 0; i < binary.size(); i++)
        cout << binary[i];
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/03ms2084 KiB
2Accepted0/03ms2220 KiB
3Accepted3/33ms2588 KiB
4Accepted3/33ms2796 KiB
5Accepted3/33ms2948 KiB
6Partially correct1/33ms3164 KiB
7Accepted3/33ms3192 KiB
8Accepted3/33ms3280 KiB
9Accepted3/33ms3252 KiB
10Partially correct1/33ms3252 KiB
11Accepted3/32ms3176 KiB
12Partially correct1/33ms3300 KiB
13Accepted4/43ms3436 KiB
14Partially correct1/42ms3500 KiB
15Accepted4/43ms3460 KiB
16Partially correct1/43ms3708 KiB
17Accepted4/43ms3792 KiB