142672025-01-10 11:13:50GundischBalazsTáblajátékcpp17Wrong answer 15/501ms512 KiB
#include <iostream>
using namespace std;
void decToBinary(int n)
{
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    long long j = 1, db = 0;
    int x;
    for(int i = 0; i < k; i++){
        cin >> x;
        if(x == 0){
            db++;
            j = 2*j;
        }
        else if(x == 1){
             db++;
             j = 2*j+1;
        }
        else if(x == 2){
            db--;
            if(j % 2 == 0)
            {
                j=j/2;
            }
            else{
                j=j/2-1;
            }
        }
        else if(x == 3){
            j--;
        }
        else{
            j++;
        }
    }
    cout << db << endl;
    decToBinary(j);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Wrong answer0/01ms328 KiB
2Wrong answer0/01ms512 KiB
3Partially correct1/31ms316 KiB
4Partially correct1/31ms316 KiB
5Partially correct1/31ms316 KiB
6Partially correct1/31ms316 KiB
7Partially correct1/31ms316 KiB
8Partially correct1/31ms316 KiB
9Partially correct1/31ms500 KiB
10Partially correct1/31ms316 KiB
11Partially correct1/31ms316 KiB
12Partially correct1/31ms508 KiB
13Partially correct1/41ms328 KiB
14Partially correct1/41ms316 KiB
15Partially correct1/41ms316 KiB
16Partially correct1/41ms508 KiB
17Partially correct1/41ms316 KiB