103782024-04-01 16:32:07MagyarKendeSZLGTúra (75 pont)cpp17Wrong answer 10/7535ms4864 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";
            return;
        }
        if (uglyNeighbor[U] && ugly[V]) {
            cout << "NEM\n3\n" << uglyNeighbor[U] << " " << U << " " << V << "\n";
            return;
        }
        if (ugly[U] && uglyNeighbor[V]) {
            cout << "NEM\n3\n" << uglyNeighbor[V] << " " << V << " " << U << "\n"; 
            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
base10/75
1Accepted0/03ms2104 KiB
2Wrong answer0/03ms2144 KiB
3Wrong answer0/63ms2332 KiB
4Wrong answer0/34ms2572 KiB
5Wrong answer0/33ms2632 KiB
6Wrong answer0/43ms2764 KiB
7Wrong answer0/43ms2848 KiB
8Wrong answer0/43ms2896 KiB
9Runtime error0/210ms3092 KiB
10Wrong answer0/26ms3108 KiB
11Runtime error0/214ms3432 KiB
12Wrong answer0/212ms3364 KiB
13Wrong answer0/28ms3364 KiB
14Runtime error0/38ms3564 KiB
15Wrong answer0/26ms3588 KiB
16Accepted2/228ms3800 KiB
17Runtime error0/220ms3896 KiB
18Wrong answer0/221ms3912 KiB
19Wrong answer0/38ms4016 KiB
20Wrong answer0/229ms4248 KiB
21Wrong answer0/28ms4248 KiB
22Wrong answer0/36ms4224 KiB
23Accepted2/29ms4252 KiB
24Accepted2/230ms4408 KiB
25Wrong answer0/28ms4352 KiB
26Wrong answer0/219ms4440 KiB
27Wrong answer0/225ms4440 KiB
28Wrong answer0/213ms4484 KiB
29Wrong answer0/213ms4696 KiB
30Wrong answer0/219ms4784 KiB
31Accepted2/234ms4780 KiB
32Accepted2/235ms4864 KiB