71402023-12-31 12:58:03xxxTúra (75 pont)cpp17Wrong answer 26/7554ms40264 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) {
                            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
base26/75
1Wrong answer0/03ms2100 KiB
2Wrong answer0/03ms2076 KiB
3Wrong answer0/63ms2288 KiB
4Wrong answer0/37ms2840 KiB
5Accepted3/37ms3028 KiB
6Accepted4/47ms3080 KiB
7Wrong answer0/47ms3192 KiB
8Wrong answer0/47ms3356 KiB
9Wrong answer0/245ms5792 KiB
10Wrong answer0/246ms7216 KiB
11Wrong answer0/245ms8740 KiB
12Wrong answer0/246ms9916 KiB
13Wrong answer0/245ms11040 KiB
14Wrong answer0/345ms12032 KiB
15Wrong answer0/245ms13328 KiB
16Wrong answer0/245ms14348 KiB
17Wrong answer0/245ms15756 KiB
18Wrong answer0/245ms17216 KiB
19Wrong answer0/343ms18456 KiB
20Wrong answer0/243ms19556 KiB
21Accepted2/245ms20724 KiB
22Accepted3/346ms21844 KiB
23Accepted2/250ms34304 KiB
24Accepted2/252ms35012 KiB
25Accepted2/254ms30528 KiB
26Accepted2/250ms32572 KiB
27Wrong answer0/252ms33388 KiB
28Accepted2/248ms35224 KiB
29Accepted2/252ms35976 KiB
30Accepted2/248ms37832 KiB
31Wrong answer0/250ms38964 KiB
32Wrong answer0/254ms40264 KiB