40892023-03-13 16:49:54xxxTúra (75 pont)cpp14Wrong answer 0/7593ms14132 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++) {
        for (int j = 0; j < a[sztas[i]].size(); j++) {
            if (tisztas[a[i][j]] == -1) {
                cout << "NEM" << endl << 2 << endl;
                cout << i+1 << " " << a[i][j]+1 << endl;
                return;
            } else {
                for (int k = 0; k < a[a[i][j]].size(); k++) {
                    if (tisztas[a[a[i][j]][k]] == -1) {
                        cout << "NEM" << endl << 3 << endl;
                        cout << i+1 << " " << a[i][j]+1 << " " << a[a[i][j]][k]+1 << endl;
                        return;
                    }
                }
            }
        }
    }
    cout << "IGEN" << endl;

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

}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/03ms1812 KiB
2Runtime error0/03ms2100 KiB
3Runtime error0/63ms2060 KiB
4Runtime error0/33ms2228 KiB
5Runtime error0/33ms2456 KiB
6Runtime error0/44ms2688 KiB
7Runtime error0/43ms2756 KiB
8Runtime error0/43ms2876 KiB
9Runtime error0/210ms4340 KiB
10Runtime error0/210ms4628 KiB
11Runtime error0/210ms4592 KiB
12Runtime error0/210ms5168 KiB
13Runtime error0/218ms5272 KiB
14Runtime error0/310ms4976 KiB
15Runtime error0/210ms5148 KiB
16Runtime error0/217ms5024 KiB
17Runtime error0/210ms4988 KiB
18Runtime error0/210ms4968 KiB
19Runtime error0/310ms5252 KiB
20Runtime error0/29ms5320 KiB
21Runtime error0/227ms5220 KiB
22Runtime error0/318ms5308 KiB
23Runtime error0/290ms13616 KiB
24Runtime error0/293ms14132 KiB
25Runtime error0/246ms9480 KiB
26Runtime error0/246ms9048 KiB
27Runtime error0/246ms9464 KiB
28Runtime error0/246ms9164 KiB
29Runtime error0/292ms9696 KiB
30Runtime error0/246ms9252 KiB
31Runtime error0/246ms9352 KiB
32Runtime error0/292ms9656 KiB