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

int main()
{
    int n;
    cin >> n;
    int64_t x = 1;
    int64_t 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/03ms1812 KiB
2Accepted0/03ms2000 KiB
3Accepted3/33ms2252 KiB
4Accepted3/33ms2428 KiB
5Accepted3/33ms2512 KiB
6Partially correct1/33ms2644 KiB
7Accepted3/33ms2848 KiB
8Accepted3/33ms3060 KiB
9Accepted3/33ms3312 KiB
10Partially correct1/33ms3388 KiB
11Accepted3/33ms3516 KiB
12Partially correct1/33ms3640 KiB
13Accepted4/43ms3636 KiB
14Partially correct1/43ms3608 KiB
15Accepted4/43ms3704 KiB
16Partially correct1/43ms3912 KiB
17Accepted4/43ms3996 KiB