34542023-02-28 09:58:40CWMTáblajátékcpp17Wrong answer 30/503ms3816 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;
            }
        }
        else if (ins == 4) {
            for (size_t i = 0; i < nbitnum.size(); i++)
            {
                if (nbitnum[i] == 1) nbitnum[i] = 0;
                else nbitnum[i] = 1;
            }
        }
    }
    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;
}

// 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
base30/50
1Accepted0/03ms1808 KiB
2Wrong answer0/03ms2004 KiB
3Accepted3/33ms2212 KiB
4Accepted3/33ms2464 KiB
5Accepted3/33ms2664 KiB
6Accepted3/33ms2756 KiB
7Accepted3/33ms2876 KiB
8Accepted3/33ms3096 KiB
9Partially correct1/33ms3148 KiB
10Partially correct1/33ms3424 KiB
11Partially correct1/33ms3272 KiB
12Partially correct1/33ms3404 KiB
13Partially correct1/43ms3520 KiB
14Partially correct1/43ms3548 KiB
15Partially correct1/43ms3604 KiB
16Partially correct1/43ms3736 KiB
17Accepted4/43ms3816 KiB