4090 2023. 03. 13 17:01:04 xxx Túra (75 pont) cpp14 Wrong answer 15/75 98ms 14432 KiB
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> tisztas(n);
    vector<int> a[n], sztas;
    for (int i = 0; i < n; i++) {
        cin >> tisztas[i];
        if (tisztas[i] == -1) sztas.push_back(i);
    }
    for (int i = 0; i < n-1; i++) {
        int x, y;
        cin >> x >> y;
        a[x-1].push_back(y-1);
    }
    //for (int i = 0; i < sztas.size(); i++) cout << sztas[i] << " ";

    for (int i = 0; i < sztas.size(); i++) {
        for (int j = 0; j < a[sztas[i]].size(); j++) {
            if (tisztas[a[sztas[i]][j]] == -1) {
                cout << "NEM" << endl << 2 << endl;
                cout << sztas[i]+1 << " " << a[sztas[i]][j]+1 << endl;
                return;
            } else {
                for (int k = 0; k < a[a[sztas[i]][j]].size(); k++) {
                    if (tisztas[a[a[sztas[i]][j]][k]] == -1) {
                        cout << "NEM" << endl << 3 << endl;
                        cout << sztas[i]+1 << " " << a[sztas[i]][j]+1 << " " << a[a[i][j]][k]+1 << endl;
                        return;
                    }
                }
            }
        }
    }
    cout << "IGEN" << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }

}
Subtask Sum Test Verdict Time Memory
base 15/75
1 Accepted 0/0 3ms 1808 KiB
2 Wrong answer 0/0 3ms 2004 KiB
3 Wrong answer 0/6 3ms 2216 KiB
4 Accepted 3/3 9ms 2636 KiB
5 Runtime error 0/3 3ms 2900 KiB
6 Runtime error 0/4 4ms 2996 KiB
7 Runtime error 0/4 4ms 2980 KiB
8 Runtime error 0/4 4ms 3064 KiB
9 Runtime error 0/2 10ms 3980 KiB
10 Accepted 2/2 83ms 3740 KiB
11 Runtime error 0/2 75ms 4116 KiB
12 Runtime error 0/2 75ms 4452 KiB
13 Runtime error 0/2 10ms 4476 KiB
14 Runtime error 0/3 27ms 4432 KiB
15 Accepted 2/2 83ms 4592 KiB
16 Accepted 2/2 83ms 4684 KiB
17 Runtime error 0/2 68ms 5040 KiB
18 Runtime error 0/2 67ms 5036 KiB
19 Runtime error 0/3 10ms 5028 KiB
20 Wrong answer 0/2 82ms 5188 KiB
21 Runtime error 0/2 10ms 5416 KiB
22 Runtime error 0/3 68ms 5392 KiB
23 Wrong answer 0/2 93ms 13552 KiB
24 Runtime error 0/2 92ms 14432 KiB
25 Runtime error 0/2 92ms 9424 KiB
26 Wrong answer 0/2 90ms 9148 KiB
27 Wrong answer 0/2 92ms 9472 KiB
28 Runtime error 0/2 46ms 9388 KiB
29 Accepted 2/2 96ms 9928 KiB
30 Runtime error 0/2 46ms 9348 KiB
31 Accepted 2/2 93ms 9448 KiB
32 Accepted 2/2 98ms 9832 KiB