71412023-12-31 13:00:51xxxTúra (75 pont)cpp17Accepted 75/7556ms16520 KiB
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> t(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> t[i];
    }

    vector<vector<int> > adj(n+1);

    for(int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for(int i = 1; i <= n; i++) {
        if (t[i] == -1) {
            for(auto u : adj[i]) {
                if (t[u] == -1) {
                    cout << "NEM\n";
                    cout << 2 << '\n' << i << ' ' << u << '\n';
                    return;
                } else {
                    for(auto v : adj[u]) {
                        if (t[v] == -1 && v != i) {
                            cout << "NEM\n";
                            cout << 3 << '\n' << i << ' ' << u << ' ' << v << '\n';
                            return;
                        }
                    }
                }
            }
        }
    }
    cout << "IGEN\n";

}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int tt;
	cin >> tt;
	while(tt--) {
        solve();
	}


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms2108 KiB
2Accepted0/03ms2244 KiB
3Accepted6/63ms2280 KiB
4Accepted3/37ms2556 KiB
5Accepted3/37ms2840 KiB
6Accepted4/47ms2872 KiB
7Accepted4/47ms3044 KiB
8Accepted4/47ms3092 KiB
9Accepted2/243ms4140 KiB
10Accepted2/245ms4020 KiB
11Accepted2/245ms4272 KiB
12Accepted2/245ms4292 KiB
13Accepted2/243ms4220 KiB
14Accepted3/343ms4480 KiB
15Accepted2/245ms4504 KiB
16Accepted2/243ms4692 KiB
17Accepted2/245ms4972 KiB
18Accepted2/243ms4984 KiB
19Accepted3/343ms5104 KiB
20Accepted2/241ms5232 KiB
21Accepted2/243ms5336 KiB
22Accepted3/346ms5244 KiB
23Accepted2/248ms16520 KiB
24Accepted2/250ms15868 KiB
25Accepted2/250ms10176 KiB
26Accepted2/246ms10772 KiB
27Accepted2/250ms10264 KiB
28Accepted2/246ms10892 KiB
29Accepted2/252ms10264 KiB
30Accepted2/246ms11000 KiB
31Accepted2/250ms10776 KiB
32Accepted2/256ms10472 KiB