28782023-02-01 13:57:35tamasmarkTáblajátékcpp17Részben helyes 36/503ms3796 KiB
// tablajatek.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int n, sor, hely, i, a;
deque<int>x;

int main()
{
    cin >> n;
    for (i = 1; i<=n; ++i)
    {
        cin >> a;
        if (a == 0)
        {
            sor++;
            hely = hely * 2;
        }
        else if (a == 1)
        {
            sor++;
            hely = (hely * 2) + 1;

        }
        else if (a == 2)
        {
            sor--;
            if (hely % 2 == 0)
            {
                hely = hely / 2;
            }
            else if (hely % 2 != 0)
            {
                hely = hely - 1;
                hely = hely / 2;
            }
        }
        else if (a == 3)
        {
            hely--;
        }
        else if (a == 4)
        {
            hely++;
        }
    }
    //a = hely;
    while (hely / 2)
    {
        if (hely % 2==0)
        {
            x.push_front(0);
        }
        else
        {
            x.push_front(1);
        }
        hely = hely / 2;
    }
    if (hely % 2 == 0) x.push_front(0);
    else x.push_front(1);
    cout << sor << "\n";
    for (i = 0; i < x.size(); ++i)
    {
        cout << x[i];
    }
    return 0;
}
/*
6 
0 1 4 2 1 0
6 
0 0 0 0 0 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
base36/50
1Elfogadva0/03ms1812 KiB
2Elfogadva0/03ms2052 KiB
3Elfogadva3/33ms2128 KiB
4Elfogadva3/33ms2328 KiB
5Elfogadva3/33ms2572 KiB
6Részben helyes1/33ms2816 KiB
7Elfogadva3/33ms2992 KiB
8Részben helyes1/33ms3112 KiB
9Elfogadva3/32ms3112 KiB
10Részben helyes1/33ms3044 KiB
11Elfogadva3/33ms3176 KiB
12Részben helyes1/33ms3432 KiB
13Elfogadva4/42ms3476 KiB
14Részben helyes1/43ms3708 KiB
15Elfogadva4/42ms3796 KiB
16Részben helyes1/43ms3684 KiB
17Elfogadva4/42ms3680 KiB