33952023-02-27 12:20:06AblablablaTáblajátékcpp17Partially correct 29/503ms3480 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++;
        }
    }

    //szelesseg = 100;
    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/03ms2152 KiB
3Partially correct1/33ms2288 KiB
4Accepted3/33ms2500 KiB
5Accepted3/33ms2588 KiB
6Partially correct1/33ms2608 KiB
7Accepted3/33ms2748 KiB
8Partially correct1/33ms2764 KiB
9Partially correct1/33ms2912 KiB
10Partially correct1/33ms3036 KiB
11Accepted3/33ms3308 KiB
12Partially correct1/33ms3408 KiB
13Accepted4/43ms3356 KiB
14Partially correct1/43ms3268 KiB
15Accepted4/43ms3264 KiB
16Partially correct1/43ms3480 KiB
17Partially correct1/43ms3412 KiB