88992024-02-03 17:23:59IgnácTúra (75 pont)cpp17Wrong answer 14/7586ms23024 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) {
				cout << "NEM\n2\n" << a << " " << b << "\n";
				found = true;
				break;
			}
			
			if (db[a - 1] != 0 && jo[b - 1] == -1) {
				cout << "NEM\n3\n" << db[a - 1] << " " << a << " " << b << "\n";
				found = true;
				break;
			}

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

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

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

		if (!found) cout << "IGEN" << "\n";
	}
}
SubtaskSumTestVerdictTimeMemory
base14/75
1Accepted0/03ms1956 KiB
2Wrong answer0/03ms2136 KiB
3Runtime error0/66ms2848 KiB
4Wrong answer0/34ms2732 KiB
5Wrong answer0/34ms2836 KiB
6Wrong answer0/43ms3056 KiB
7Wrong answer0/43ms3152 KiB
8Wrong answer0/44ms3464 KiB
9Wrong answer0/210ms4084 KiB
10Wrong answer0/210ms4628 KiB
11Wrong answer0/232ms5528 KiB
12Wrong answer0/228ms6116 KiB
13Runtime error0/221ms6876 KiB
14Runtime error0/320ms7452 KiB
15Wrong answer0/226ms7864 KiB
16Accepted2/271ms8908 KiB
17Wrong answer0/257ms9952 KiB
18Wrong answer0/254ms11216 KiB
19Wrong answer0/312ms11560 KiB
20Accepted2/275ms12696 KiB
21Wrong answer0/226ms13204 KiB
22Runtime error0/314ms13916 KiB
23Accepted2/220ms15304 KiB
24Accepted2/282ms16740 KiB
25Runtime error0/214ms16392 KiB
26Wrong answer0/250ms17248 KiB
27Accepted2/263ms18516 KiB
28Runtime error0/225ms19028 KiB
29Runtime error0/226ms19400 KiB
30Wrong answer0/252ms20252 KiB
31Accepted2/285ms21644 KiB
32Accepted2/286ms23024 KiB