40902023-03-13 17:01:04xxxTúra (75 pont)cpp14Wrong answer 15/7598ms14432 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();
    }

}
SubtaskSumTestVerdictTimeMemory
base15/75
1Accepted0/03ms1808 KiB
2Wrong answer0/03ms2004 KiB
3Wrong answer0/63ms2216 KiB
4Accepted3/39ms2636 KiB
5Runtime error0/33ms2900 KiB
6Runtime error0/44ms2996 KiB
7Runtime error0/44ms2980 KiB
8Runtime error0/44ms3064 KiB
9Runtime error0/210ms3980 KiB
10Accepted2/283ms3740 KiB
11Runtime error0/275ms4116 KiB
12Runtime error0/275ms4452 KiB
13Runtime error0/210ms4476 KiB
14Runtime error0/327ms4432 KiB
15Accepted2/283ms4592 KiB
16Accepted2/283ms4684 KiB
17Runtime error0/268ms5040 KiB
18Runtime error0/267ms5036 KiB
19Runtime error0/310ms5028 KiB
20Wrong answer0/282ms5188 KiB
21Runtime error0/210ms5416 KiB
22Runtime error0/368ms5392 KiB
23Wrong answer0/293ms13552 KiB
24Runtime error0/292ms14432 KiB
25Runtime error0/292ms9424 KiB
26Wrong answer0/290ms9148 KiB
27Wrong answer0/292ms9472 KiB
28Runtime error0/246ms9388 KiB
29Accepted2/296ms9928 KiB
30Runtime error0/246ms9348 KiB
31Accepted2/293ms9448 KiB
32Accepted2/298ms9832 KiB