34562023-02-28 10:12:55CWMTáblajátékcpp17Hibás válasz 30/503ms3796 KiB
// nemesGyak000.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<int> nbitnum;
    int n;
    cin >> n;
    int level = 0;
    for (size_t i = 0; i < n; i++)
    {
        int ins;
        cin >> ins;
        if (ins == 0) {
            nbitnum.push_back(0);
            level++;
        }
        else if (ins == 1) {
            nbitnum.push_back(1);
            level++;
        }
        else if (ins == 2) {
            nbitnum.pop_back();
            level--;
        }
        else if (ins == 3) {
            for (size_t i = 0; i < nbitnum.size(); i++)
            {
                if (nbitnum[i] == 0) nbitnum[i] = 1;
                else {
                    nbitnum[i] = 0;
                    break;
                }
            }
        }
        else if (ins == 4) {
            bool tV = false;
            for (size_t i = 0; i < nbitnum.size(); i++)
            {
                if (nbitnum[i] == 1) nbitnum[i] = 0;
                else {
                    nbitnum[i] = 1;
                    tV = true;
                    break;
                }
            }
            if (!tV) {
                nbitnum[0] = 1;
                nbitnum.push_back(0);
            }
        }
    }
    string res = "";
    bool hadOne = false;
    for (size_t i = 0; i < nbitnum.size(); i++)
    {
        if (nbitnum[i] == 0 && hadOne) {
            res += '0';
        }
        else if (nbitnum[i] == 1) {
            hadOne = true;
            res += '1';
        }
    }
    if (res == "") res = "0";
    cout << level << "\n" << res << "\n";
}

// 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
base30/50
1Elfogadva0/03ms1680 KiB
2Hibás válasz0/03ms1848 KiB
3Elfogadva3/33ms2064 KiB
4Elfogadva3/33ms2276 KiB
5Elfogadva3/32ms2360 KiB
6Elfogadva3/33ms2492 KiB
7Elfogadva3/33ms2728 KiB
8Elfogadva3/33ms2940 KiB
9Részben helyes1/33ms3024 KiB
10Részben helyes1/33ms3124 KiB
11Részben helyes1/33ms3332 KiB
12Részben helyes1/33ms3580 KiB
13Részben helyes1/42ms3668 KiB
14Részben helyes1/43ms3668 KiB
15Részben helyes1/42ms3676 KiB
16Részben helyes1/43ms3664 KiB
17Elfogadva4/43ms3796 KiB