37352023-03-02 16:10:06grengBürokrácia (40)cpp11Wrong answer 13/40400ms6252 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, int pos) {
    if (torvenyek[j-1].first == 'R') {
        ervenytelen[j - 1] += pos;
        return;
    }
    else {
        ervenytelen[torvenyek[j - 1].second - 1] -= pos;
        if (!ervenytelen[torvenyek[j - 1].second - 1] && torvenyek[torvenyek[j - 1].second - 1].first == 'V') {
            visszavon(torvenyek[torvenyek[j - 1].second - 1].second, -1);
        }
        ervenytelen[j - 1] += pos;
        if(!ervenytelen[j-1])
            visszavon(torvenyek[j - 1].second, 1);
    }

}



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

    return db;
}


int main()
{
    in();
    process();
}
SubtaskSumTestVerdictTimeMemory
base13/40
1Accepted0/03ms1812 KiB
2Accepted1/12ms2056 KiB
3Wrong answer0/13ms2300 KiB
4Wrong answer0/13ms2528 KiB
5Accepted1/123ms4936 KiB
6Time limit exceeded0/1400ms3392 KiB
7Accepted1/150ms5120 KiB
8Wrong answer0/246ms5116 KiB
9Wrong answer0/248ms5168 KiB
10Wrong answer0/248ms5164 KiB
11Wrong answer0/248ms5308 KiB
12Accepted2/225ms5556 KiB
13Wrong answer0/225ms5364 KiB
14Wrong answer0/246ms5512 KiB
15Wrong answer0/237ms5716 KiB
16Accepted2/225ms5660 KiB
17Wrong answer0/225ms5592 KiB
18Wrong answer0/225ms5592 KiB
19Accepted2/223ms5924 KiB
20Accepted2/223ms6116 KiB
21Accepted2/224ms6252 KiB
22Time limit exceeded0/2347ms4372 KiB
23Wrong answer0/450ms6168 KiB