21772022-12-29 01:12:01TuruTamasBürokrácia (40)cpp11Accepted 40/4054ms11208 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N; cin >> N;
    int * type = new int[N];
    for (int i = 0; i < N; i++)
    {
        char c; cin >> c;
        if (c == 'V') {
            int v; cin >> v;
            type[i] = v - 1;
        }
        else {
            type[i] = -1;
        }
    }
    bool * active = new bool[N];
    fill(active, active + N, true);
    list<int> r;
    for (int i = N - 1; i >= 0; i--)
    {
        if (active[i]) {
            r.push_front(i);
            if (type[i] != -1) {
                active[type[i]] = false;
            }
        }
    }
    cout << r.size() << '\n';
    for (auto it = r.begin(); it != r.end(); ++it)
    {
        cout << ((*it) + 1) << ' ';
    }
    cout << endl;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1816 KiB
2Accepted1/12ms2052 KiB
3Accepted1/12ms2300 KiB
4Accepted1/12ms2436 KiB
5Accepted1/128ms9836 KiB
6Accepted1/152ms6812 KiB
7Accepted1/148ms6972 KiB
8Accepted2/250ms7500 KiB
9Accepted2/252ms7632 KiB
10Accepted2/250ms7708 KiB
11Accepted2/250ms8176 KiB
12Accepted2/230ms9880 KiB
13Accepted2/230ms9936 KiB
14Accepted2/248ms8396 KiB
15Accepted2/241ms9008 KiB
16Accepted2/229ms10216 KiB
17Accepted2/230ms10484 KiB
18Accepted2/230ms10440 KiB
19Accepted2/228ms10956 KiB
20Accepted2/228ms11208 KiB
21Accepted2/228ms11028 KiB
22Accepted2/250ms7936 KiB
23Accepted4/454ms8268 KiB