194752025-12-10 13:36:48gkataTáblajátékcpp17Részben helyes 38/501ms512 KiB
// tablajatek.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#define ll long long

using namespace std;

ll sz = 0, m = 0, n, i, a;
deque <ll>x;

int main()
{
    cin >> n;
    for (i = 1; i <= n; ++i)
    {
        cin >> a;

        if (a == 0)
        {
            m = m * 2;
            sz = sz + 1;
        }

        if (a == 1)
        {
            m = m * 2 + 1;
            sz = sz + 1;
        }

        if (a == 2)
        {
            if (!(m % 2))   m = m / 2;
            else m = (m - 1) / 2;
            sz -= 1;
        }

        if (a == 3) m -= 1;
        if (a == 4) m += 1;
    }

    while (m)
    {
        x.push_front(m % 2);
        m = m / 2;
    }
    cout << sz << " " << endl;

    for (i = 0; i < x.size(); ++i) if (x[i]) break;
    for (; i < x.size(); ++i) cout << x[i];

    if (x.empty()) cout << 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
RészfeladatÖsszpontTesztVerdiktIdőMemória
base38/50
1Elfogadva0/01ms316 KiB
2Elfogadva0/01ms316 KiB
3Elfogadva3/31ms508 KiB
4Elfogadva3/31ms316 KiB
5Elfogadva3/31ms316 KiB
6Részben helyes1/31ms316 KiB
7Elfogadva3/31ms316 KiB
8Elfogadva3/31ms316 KiB
9Elfogadva3/31ms316 KiB
10Részben helyes1/31ms316 KiB
11Elfogadva3/31ms316 KiB
12Részben helyes1/31ms372 KiB
13Elfogadva4/41ms316 KiB
14Részben helyes1/41ms316 KiB
15Elfogadva4/41ms316 KiB
16Részben helyes1/41ms512 KiB
17Elfogadva4/41ms316 KiB