89002024-02-03 17:46:34IgnácTúra (75 pont)cpp17Wrong answer 24/7589ms10556 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 << i << " ";
				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
base24/75
1Accepted0/03ms1956 KiB
2Wrong answer0/03ms2088 KiB
3Wrong answer0/63ms2328 KiB
4Wrong answer0/38ms2404 KiB
5Wrong answer0/38ms2640 KiB
6Wrong answer0/48ms2828 KiB
7Wrong answer0/48ms3040 KiB
8Wrong answer0/48ms3124 KiB
9Wrong answer0/275ms3452 KiB
10Accepted2/276ms3544 KiB
11Accepted2/276ms3756 KiB
12Accepted2/276ms3968 KiB
13Wrong answer0/276ms4820 KiB
14Wrong answer0/376ms5456 KiB
15Accepted2/278ms5468 KiB
16Accepted2/276ms5384 KiB
17Wrong answer0/276ms5640 KiB
18Wrong answer0/275ms5868 KiB
19Wrong answer0/376ms5840 KiB
20Wrong answer0/275ms5848 KiB
21Wrong answer0/279ms6120 KiB
22Wrong answer0/379ms6944 KiB
23Accepted2/285ms8156 KiB
24Accepted2/289ms8240 KiB
25Accepted2/282ms8724 KiB
26Wrong answer0/283ms8748 KiB
27Wrong answer0/282ms8836 KiB
28Accepted2/282ms9492 KiB
29Accepted2/286ms10476 KiB
30Wrong answer0/285ms10556 KiB
31Accepted2/285ms10556 KiB
32Accepted2/286ms10556 KiB