63932023-11-27 11:05:12MrChipserTáblajátékcpp11Partially correct 36/503ms4036 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int x = 1;
    int 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
base36/50
1Accepted0/03ms1808 KiB
2Accepted0/03ms1932 KiB
3Accepted3/33ms2148 KiB
4Accepted3/32ms2236 KiB
5Accepted3/33ms2292 KiB
6Partially correct1/33ms2528 KiB
7Accepted3/33ms2780 KiB
8Partially correct1/33ms2872 KiB
9Accepted3/33ms3008 KiB
10Partially correct1/33ms3380 KiB
11Accepted3/33ms3372 KiB
12Partially correct1/33ms3440 KiB
13Accepted4/43ms3564 KiB
14Partially correct1/43ms3652 KiB
15Accepted4/43ms3732 KiB
16Partially correct1/43ms3944 KiB
17Accepted4/43ms4036 KiB