7192021-12-21 10:37:15kidesoBürokrácia (40)cpp11Wrong answer 13/40365ms6424 KiB
#include <iostream>
#include <vector>

using namespace std;

struct adat { int erv, cel; };
vector <adat> x;
int N;

void cs(int k, int h)
{
    if (x[k].cel == 0) return;
    x[x[k].cel].erv += h;
    cs(x[k].cel, -h);
}

int main()
{
    cin >> N;
    x.resize(N + 1);
    char tip;
    int c;

    for (int i = 1; i <= N; ++i)
    {
        cin >> tip;
        if (tip == 'R') x[i].erv = 0;
        else
        {
            cin >> c;
            x[i].cel = c;
            cs(i, 1);
        }
    }

    vector <int> r;
    for (int i = 1; i <= N; ++i)
        if (x[i].erv == 0) r.push_back(i);

    cout << r.size() << '\n';
    for (auto e : r)
        cout << e << ' ';

    return 0;
}
/*
7
R
V 1
R
V 2
V 3
V 3
V 5
*/
SubtaskSumTestVerdictTimeMemory
base13/40
1Accepted0/03ms1808 KiB
2Accepted1/12ms2056 KiB
3Wrong answer0/12ms2152 KiB
4Wrong answer0/12ms2324 KiB
5Accepted1/123ms5208 KiB
6Time limit exceeded0/1347ms2596 KiB
7Accepted1/148ms4972 KiB
8Wrong answer0/248ms5180 KiB
9Wrong answer0/250ms5232 KiB
10Wrong answer0/252ms5292 KiB
11Wrong answer0/250ms5492 KiB
12Accepted2/226ms6080 KiB
13Wrong answer0/225ms6076 KiB
14Wrong answer0/246ms5800 KiB
15Wrong answer0/237ms6088 KiB
16Accepted2/225ms6092 KiB
17Wrong answer0/226ms6088 KiB
18Wrong answer0/225ms6092 KiB
19Accepted2/223ms6300 KiB
20Accepted2/223ms6292 KiB
21Accepted2/223ms6424 KiB
22Time limit exceeded0/2331ms6072 KiB
23Time limit exceeded0/4365ms3888 KiB