37342023-03-02 16:04:06grengBürokrácia (40)cpp11Wrong answer 8/40365ms6964 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') {
        if (pos == 1)
            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
base8/40
1Accepted0/03ms1812 KiB
2Accepted1/13ms2052 KiB
3Wrong answer0/13ms2264 KiB
4Wrong answer0/13ms2492 KiB
5Accepted1/124ms5080 KiB
6Time limit exceeded0/1365ms3524 KiB
7Wrong answer0/150ms5200 KiB
8Wrong answer0/248ms5532 KiB
9Wrong answer0/248ms5744 KiB
10Wrong answer0/248ms5880 KiB
11Wrong answer0/248ms6088 KiB
12Wrong answer0/226ms6300 KiB
13Wrong answer0/226ms6256 KiB
14Wrong answer0/246ms6260 KiB
15Wrong answer0/237ms6516 KiB
16Wrong answer0/225ms6472 KiB
17Wrong answer0/226ms6732 KiB
18Wrong answer0/225ms6796 KiB
19Accepted2/223ms6684 KiB
20Accepted2/223ms6940 KiB
21Accepted2/223ms6892 KiB
22Time limit exceeded0/2344ms5108 KiB
23Wrong answer0/452ms6964 KiB