103792024-04-01 16:36:19MagyarKendeSZLGTúra (75 pont)cpp17Wrong answer 18/7537ms4304 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define all(v) v.begin(), v.end()

void solve() {
    int N;
    cin >> N;
    vector<bool> ugly(N + 1), uglyNeighbor(N + 1);

    for (int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        ugly[i] = A == -1;
    }

    for (int i = 1; i < N; i++) {
        int U, V;
        cin >> U >> V;
        if (ugly[U] && ugly[V]) {
            cout << "NEM\n2\n" << U << " " << V << "\n";
            for (i++; i < N; i++) cin >> U >> V;
            return;
        }
        if (uglyNeighbor[U] && ugly[V]) {
            cout << "NEM\n3\n" << uglyNeighbor[U] << " " << U << " " << V << "\n";
            for (i++; i < N; i++) cin >> U >> V;
            return;
        }
        if (ugly[U] && uglyNeighbor[V]) {
            cout << "NEM\n3\n" << uglyNeighbor[V] << " " << V << " " << U << "\n"; 
            for (i++; i < N; i++) cin >> U >> V;
            return;
        }
        if (ugly[U]) {
            uglyNeighbor[V] = U;
        }
        if (ugly[V]) {
            uglyNeighbor[U] = V;
        }
    }

    cout << "IGEN\n";
}

int main() {
	cin.tie(0), ios::sync_with_stdio(0);
    int T;
    cin >> T;
    while (T--) solve();
}
SubtaskSumTestVerdictTimeMemory
base18/75
1Accepted0/03ms1824 KiB
2Wrong answer0/03ms2028 KiB
3Wrong answer0/63ms2252 KiB
4Wrong answer0/34ms2448 KiB
5Wrong answer0/34ms2664 KiB
6Wrong answer0/44ms2640 KiB
7Wrong answer0/44ms2764 KiB
8Wrong answer0/44ms2976 KiB
9Wrong answer0/230ms3060 KiB
10Accepted2/232ms3060 KiB
11Wrong answer0/232ms3056 KiB
12Wrong answer0/232ms3056 KiB
13Wrong answer0/232ms3412 KiB
14Wrong answer0/332ms3644 KiB
15Accepted2/232ms3644 KiB
16Accepted2/232ms3728 KiB
17Wrong answer0/232ms3988 KiB
18Wrong answer0/232ms4032 KiB
19Wrong answer0/332ms3948 KiB
20Wrong answer0/230ms3944 KiB
21Wrong answer0/232ms3948 KiB
22Wrong answer0/332ms3952 KiB
23Accepted2/232ms3968 KiB
24Accepted2/234ms4044 KiB
25Accepted2/234ms4036 KiB
26Wrong answer0/234ms4304 KiB
27Wrong answer0/234ms4172 KiB
28Wrong answer0/234ms4176 KiB
29Accepted2/235ms4168 KiB
30Wrong answer0/234ms4172 KiB
31Accepted2/235ms4252 KiB
32Accepted2/237ms4260 KiB