89012024-02-03 17:47:11IgnácTúra (75 pont)cpp17Accepted 75/7590ms5452 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> jo(n), db(n);
		for (int i = 0; i < n; i++) {
			cin >> jo[i];
		}


		bool found = false;
		for (int i = 0; i < n - 1; i++) {
			int a, b;
			cin >> a >> b;
			if ((jo[a - 1] == -1 && jo[b - 1] == -1) && !found) {
				cout << "NEM\n2\n" << a << " " << b << "\n";
				found = true;
			}
			
			if ((db[a - 1] != 0 && jo[b - 1] == -1) && !found) {
				cout << "NEM\n3\n" << db[a - 1] << " " << a << " " << b << "\n";
				found = true;
			}

			if ((db[b - 1] != 0 && jo[a - 1] == -1) && !found) {
				cout << "NEM\n3\n" << db[b - 1] << " " << b << " " << a << "\n";
				found = true;
			}

			if (jo[a - 1] == -1) {
				db[b - 1] = a;
			}

			if (jo[b - 1] == -1) {
				db[a - 1] = b;
			}
		}

		if (!found) cout << "IGEN" << "\n";
	}
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1812 KiB
2Accepted0/03ms2064 KiB
3Accepted6/63ms2212 KiB
4Accepted3/38ms2432 KiB
5Accepted3/39ms2796 KiB
6Accepted4/48ms2920 KiB
7Accepted4/48ms3056 KiB
8Accepted4/48ms3048 KiB
9Accepted2/281ms3116 KiB
10Accepted2/279ms3120 KiB
11Accepted2/279ms3244 KiB
12Accepted2/279ms3188 KiB
13Accepted2/279ms3220 KiB
14Accepted3/379ms3440 KiB
15Accepted2/279ms3524 KiB
16Accepted2/279ms3532 KiB
17Accepted2/279ms3584 KiB
18Accepted2/279ms3532 KiB
19Accepted3/381ms3796 KiB
20Accepted2/279ms3748 KiB
21Accepted2/282ms4044 KiB
22Accepted3/382ms4040 KiB
23Accepted2/290ms5316 KiB
24Accepted2/289ms5452 KiB
25Accepted2/287ms4800 KiB
26Accepted2/289ms4804 KiB
27Accepted2/286ms4800 KiB
28Accepted2/290ms4928 KiB
29Accepted2/290ms5024 KiB
30Accepted2/289ms5012 KiB
31Accepted2/290ms5012 KiB
32Accepted2/290ms5012 KiB