193352025-12-04 21:12:00szabelrTáblajátékcpp17Wrong answer 28/501ms548 KiB
// Táblajáték.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int k, x,height=0;
    vector<int> binary;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        cin >> x;
        if (x == 0) {
            height++;
            binary.push_back(0);
        }
        if (x == 1) {
            height++;
            binary.push_back(1);
        }
        if (x == 2) {
            height--;
            binary.pop_back();
        }
        if (x == 3) {
            int egyes = -1;
            for (int y = binary.size() - 1; y >=1; y--)
            {
                if (binary[y] == 1)
                {
                    binary[y] = 0;
                    egyes = y;
                    break;
                }
            }
            if (egyes == -1) {
                binary.pop_back();
                for (int y = 0; y < binary.size() - 1; y++)
                {
                    binary[y] = 1;
                }
            }
            else
            {
                for (int y = egyes + 1; y <= binary.size() - 1; y++)
                    binary[y] = 1;
            }
        }
        if (x == 4) {
            int nulla = -1;
            for (int y = binary.size() - 1; y >= 0; y--)
            {
                if (binary[y] == 0)
                {
                    binary[y] = 1;
                    nulla = y;
                    break;
                }
            }
            if (nulla == -1) {
                binary.push_back(0);
                for (int y = 1; y < binary.size() - 1; y++)
                {
                    binary[y] = 0;
                }
            }
            else
            {
                for (int y = nulla + 1; y <= binary.size() - 1; y++)
                    binary[y] = 0;
            }
        }
    }
    cout << height << endl;
    if (binary.empty())
        cout << 0;
    for (int i = 0; i < binary.size(); i++)
    {
        cout << binary[i];
    }
}

// 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
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/01ms508 KiB
2Wrong answer0/01ms316 KiB
3Partially correct1/31ms316 KiB
4Accepted3/31ms316 KiB
5Partially correct1/31ms316 KiB
6Partially correct1/31ms316 KiB
7Partially correct1/31ms316 KiB
8Partially correct1/31ms508 KiB
9Partially correct1/31ms316 KiB
10Partially correct1/31ms548 KiB
11Accepted3/31ms404 KiB
12Partially correct1/31ms316 KiB
13Accepted4/41ms520 KiB
14Accepted4/41ms332 KiB
15Partially correct1/41ms500 KiB
16Partially correct1/41ms316 KiB
17Accepted4/41ms316 KiB