33882023-02-27 12:08:56AblablablaTáblajátékcpp11Partially correct 29/503ms3796 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> lepesek(n, 0);
    int melyseg = 0;
    int szelesseg = 0;
    for(int i = 0; i < n; i++){
        cin >> lepesek[i];
        if(lepesek[i] == 0){
            melyseg++;
            if(szelesseg != 0){
                szelesseg *= 2;
            }
        }else if(lepesek[i] == 1){
            melyseg++;
            if(szelesseg != 0){
                szelesseg = szelesseg * 2 + 1;
            } else{
                szelesseg++;
            }
        } else if(lepesek[i] == 2){
            melyseg--;
            if(szelesseg % 2 == 0){
                szelesseg /= 2;
            } else{
                szelesseg = (szelesseg - 1) / 2;
            }
        } else if(lepesek[i] == 3){
            szelesseg--;
        } else{
            szelesseg++;
        }
    }


    vector<int> valasz(0, 0);
    while(szelesseg > 0){
        int mar = szelesseg % 2;
        valasz.push_back(mar);
        szelesseg = szelesseg / 2;
    }

    cout << melyseg << "\n";
    for(int i = valasz.size() - 1; i >= 0; i--){
        cout << valasz[i];
    }
}
SubtaskSumTestVerdictTimeMemory
base29/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms1932 KiB
3Partially correct1/33ms2144 KiB
4Accepted3/32ms2232 KiB
5Accepted3/33ms2472 KiB
6Partially correct1/33ms2568 KiB
7Accepted3/32ms2652 KiB
8Partially correct1/32ms2648 KiB
9Partially correct1/32ms2660 KiB
10Partially correct1/33ms2800 KiB
11Accepted3/33ms3008 KiB
12Partially correct1/33ms3096 KiB
13Accepted4/42ms3096 KiB
14Partially correct1/43ms3332 KiB
15Accepted4/43ms3476 KiB
16Partially correct1/43ms3520 KiB
17Partially correct1/43ms3796 KiB