37302023-03-02 15:41:13grengBürokrácia (40)cpp11Wrong answer 0/4056ms6440 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++;
        }
    }
    cout << endl;
    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/02ms1812 KiB
2Wrong answer0/12ms1932 KiB
3Wrong answer0/13ms2144 KiB
4Wrong answer0/13ms2404 KiB
5Wrong answer0/123ms5004 KiB
6Wrong answer0/156ms5168 KiB
7Wrong answer0/150ms5384 KiB
8Wrong answer0/248ms5704 KiB
9Wrong answer0/248ms5772 KiB
10Wrong answer0/248ms5620 KiB
11Wrong answer0/246ms5620 KiB
12Wrong answer0/226ms5880 KiB
13Wrong answer0/226ms5952 KiB
14Wrong answer0/243ms5820 KiB
15Wrong answer0/237ms6156 KiB
16Wrong answer0/226ms6428 KiB
17Wrong answer0/225ms6388 KiB
18Wrong answer0/227ms6252 KiB
19Wrong answer0/223ms6188 KiB
20Wrong answer0/223ms6440 KiB
21Wrong answer0/223ms6400 KiB
22Wrong answer0/254ms6400 KiB
23Wrong answer0/450ms6400 KiB