89012024-02-03 17:47:11IgnácTúra (75 pont)cpp17Elfogadva 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";
	}
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base75/75
1Elfogadva0/03ms1812 KiB
2Elfogadva0/03ms2064 KiB
3Elfogadva6/63ms2212 KiB
4Elfogadva3/38ms2432 KiB
5Elfogadva3/39ms2796 KiB
6Elfogadva4/48ms2920 KiB
7Elfogadva4/48ms3056 KiB
8Elfogadva4/48ms3048 KiB
9Elfogadva2/281ms3116 KiB
10Elfogadva2/279ms3120 KiB
11Elfogadva2/279ms3244 KiB
12Elfogadva2/279ms3188 KiB
13Elfogadva2/279ms3220 KiB
14Elfogadva3/379ms3440 KiB
15Elfogadva2/279ms3524 KiB
16Elfogadva2/279ms3532 KiB
17Elfogadva2/279ms3584 KiB
18Elfogadva2/279ms3532 KiB
19Elfogadva3/381ms3796 KiB
20Elfogadva2/279ms3748 KiB
21Elfogadva2/282ms4044 KiB
22Elfogadva3/382ms4040 KiB
23Elfogadva2/290ms5316 KiB
24Elfogadva2/289ms5452 KiB
25Elfogadva2/287ms4800 KiB
26Elfogadva2/289ms4804 KiB
27Elfogadva2/286ms4800 KiB
28Elfogadva2/290ms4928 KiB
29Elfogadva2/290ms5024 KiB
30Elfogadva2/289ms5012 KiB
31Elfogadva2/290ms5012 KiB
32Elfogadva2/290ms5012 KiB