142782025-01-10 11:33:40GundischBalazsTáblajátékcpp17Wrong answer 28/501ms596 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 = 0, db = 0;
    int x;
    for(int i = 0; i < k; i++){
        cin >> x;
        if(x == 0){
            db++;
            if(j != 0){
                j=j*2;
            }
        }
        else if(x == 1){
             db++;
             j=j*2+1;
        }
        else if(x == 2){
            db--;
            if(j%2==0)
            {
                if(j == 1){
                    j=0;
                }
                else if(j%2 == 0){
                    j=j/2;
                }else{
                    j=(j-1)/2;
                }
            }
        }
        else if(x == 3){
            j--;

        }
        else{
            j++;
        }
    }
    cout << db << endl;
    if(j == 0){
        cout << j;
    }
    else{
        decToBinary(j);
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Partially correct1/31ms316 KiB
7Partially correct1/31ms316 KiB
8Partially correct1/31ms316 KiB
9Accepted3/31ms316 KiB
10Partially correct1/31ms316 KiB
11Accepted3/31ms316 KiB
12Partially correct1/31ms316 KiB
13Accepted4/41ms316 KiB
14Partially correct1/41ms316 KiB
15Partially correct1/41ms508 KiB
16Partially correct1/41ms596 KiB
17Partially correct1/41ms316 KiB