21752022-12-29 00:15:05TuruTamasBürokrácia (40)cpp11Wrong answer 8/4048ms6048 KiB
#include <bits/stdc++.h>
using namespace std;

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

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;
            g--;
            type[i] = g;
            active[i] = true;
            if (type[g] == -1) {
                active[g] = false;
            }
            else {
                reset(active, type, g);
            }
        }
        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/03ms1808 KiB
2Accepted1/12ms2004 KiB
3Wrong answer0/12ms2248 KiB
4Wrong answer0/13ms2608 KiB
5Accepted1/123ms4660 KiB
6Wrong answer0/141ms3732 KiB
7Wrong answer0/141ms4064 KiB
8Wrong answer0/243ms4252 KiB
9Wrong answer0/246ms4616 KiB
10Wrong answer0/248ms4712 KiB
11Wrong answer0/246ms4924 KiB
12Wrong answer0/226ms5484 KiB
13Wrong answer0/225ms5492 KiB
14Wrong answer0/243ms4860 KiB
15Wrong answer0/237ms5792 KiB
16Wrong answer0/225ms5736 KiB
17Wrong answer0/225ms5764 KiB
18Wrong answer0/225ms5972 KiB
19Accepted2/223ms5912 KiB
20Accepted2/223ms6048 KiB
21Accepted2/223ms6044 KiB
22Wrong answer0/241ms4876 KiB
23Wrong answer0/448ms5504 KiB