21732022-12-28 22:40:49TuruTamasBürokrácia (40)cpp11Wrong answer 8/40358ms6656 KiB
#include <bits/stdc++.h>
using namespace std;

void reset(bool * active, int * type, int g) {
    active[g] = !active[g];
    if (type[g] != -1) {
        active[g] = false;
        reset(active, type, type[g]);
    }
}

int main() {
    int N;
    cin >> N;
    bool * active = new bool[N];
    int * type = new int[N];
    for (int i = 0; i < N; i++)
    {
        char t;
        cin >> t;
        if (t == 'V') {
            int g;
            cin >> g;
            type[i] = g - 1;
            active[i] = true;
            if (type[g - 1] == -1) {
                active[g - 1] = false;
            }
            else {
                reset(active, type, g - 1);
            }
        }
        else {
            active[i] = true;
            type[i] = -1;
        }
    }
    vector<int> r;
    for (int i = 0; i < N; i++)
    {
        if (active[i]) {
            r.push_back(i + 1);
        }
    }
    cout << r.size() << '\n';
    for (int i = 0; i < r.size(); i++)
    {
        cout << r[i] << ' ';
    }
    cout << endl;
}
SubtaskSumTestVerdictTimeMemory
base8/40
1Accepted0/03ms1816 KiB
2Accepted1/12ms2060 KiB
3Wrong answer0/12ms2108 KiB
4Wrong answer0/13ms2316 KiB
5Accepted1/123ms4820 KiB
6Time limit exceeded0/1358ms2088 KiB
7Wrong answer0/145ms4148 KiB
8Wrong answer0/246ms4744 KiB
9Wrong answer0/248ms4696 KiB
10Wrong answer0/250ms5036 KiB
11Wrong answer0/248ms5236 KiB
12Wrong answer0/225ms5532 KiB
13Wrong answer0/225ms5660 KiB
14Wrong answer0/246ms5608 KiB
15Wrong answer0/237ms5952 KiB
16Wrong answer0/226ms6080 KiB
17Wrong answer0/225ms6284 KiB
18Wrong answer0/225ms6416 KiB
19Accepted2/223ms6420 KiB
20Accepted2/223ms6656 KiB
21Accepted2/223ms6536 KiB
22Wrong answer0/2275ms5476 KiB
23Time limit exceeded0/4337ms6204 KiB