37312023-03-02 15:42:22grengBürokrácia (40)cpp11Wrong answer 0/4054ms6524 KiB
#include <iostream>
#include <vector>

using namespace std;

int N;

vector<pair<char, int>> torvenyek = {};
vector<int> ervenytelen = { 0 };


void in() {
    cin >> N;
    torvenyek.reserve(N);
    ervenytelen.resize(N);
    for (int i = 0; i < ervenytelen.size(); i++) {
        ervenytelen[i] = 0;
    }
    char c;
    int j;
    for (int i = 1; i <= N; i++) {
        cin >> c;
        if (c == 'R') {
            torvenyek.push_back(pair<char, int>('R', 0));
        }
        else {
            cin >> j;
            torvenyek.push_back(pair<char, int>('V', j));
        }
    }
}

void visszavon(int j) {
    if (torvenyek[j-1].first == 'R') {
        ervenytelen[j - 1] += 1;
        return;
    }
    else {
        ervenytelen[torvenyek[j - 1].second - 1] -= 1;
        ervenytelen[j - 1] += 1;
        if(!ervenytelen[j-1])
            visszavon(torvenyek[j - 1].second);
    }

}

int process() {
    for (int i = 0; i < torvenyek.size(); i++) {
        if (torvenyek[i].first == 'V') {
            visszavon(torvenyek[i].second);
        }
    }
    int db = 0;
    for (int i = 0; i < ervenytelen.size(); i++) {
        if (!ervenytelen[i]) {
            db++;
        }
    }
    for (int i = 0; i < ervenytelen.size(); i++) {
        if (!ervenytelen[i]) {
            cout << i + 1 << " ";
        }
    }

    cout << endl;

    return db;
}

int main()
{
    in();
    cout << process();
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1684 KiB
2Wrong answer0/12ms1880 KiB
3Wrong answer0/13ms2096 KiB
4Wrong answer0/13ms2316 KiB
5Wrong answer0/123ms4904 KiB
6Wrong answer0/154ms4860 KiB
7Wrong answer0/150ms5120 KiB
8Wrong answer0/246ms5436 KiB
9Wrong answer0/246ms5644 KiB
10Wrong answer0/246ms5600 KiB
11Wrong answer0/246ms5856 KiB
12Wrong answer0/225ms5944 KiB
13Wrong answer0/226ms6092 KiB
14Wrong answer0/243ms6304 KiB
15Wrong answer0/237ms6256 KiB
16Wrong answer0/225ms6260 KiB
17Wrong answer0/226ms6392 KiB
18Wrong answer0/225ms6384 KiB
19Wrong answer0/223ms6448 KiB
20Wrong answer0/223ms6452 KiB
21Wrong answer0/223ms6324 KiB
22Wrong answer0/254ms6328 KiB
23Wrong answer0/452ms6524 KiB