103772024-04-01 16:28:54MagyarKendeSZLGTúra (75 pont)cpp17Wrong answer 10/7534ms5012 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] << " " << U << " " << V << "\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/03ms1824 KiB
2Wrong answer0/03ms2024 KiB
3Wrong answer0/63ms2248 KiB
4Wrong answer0/33ms2484 KiB
5Wrong answer0/33ms2536 KiB
6Wrong answer0/43ms2680 KiB
7Wrong answer0/43ms2760 KiB
8Wrong answer0/43ms2972 KiB
9Runtime error0/210ms3068 KiB
10Wrong answer0/26ms3056 KiB
11Runtime error0/214ms3296 KiB
12Wrong answer0/210ms3408 KiB
13Wrong answer0/28ms3608 KiB
14Runtime error0/38ms3796 KiB
15Wrong answer0/26ms3800 KiB
16Accepted2/228ms3696 KiB
17Runtime error0/220ms3800 KiB
18Wrong answer0/221ms3724 KiB
19Wrong answer0/38ms3804 KiB
20Wrong answer0/228ms4028 KiB
21Wrong answer0/28ms4116 KiB
22Wrong answer0/36ms4112 KiB
23Accepted2/29ms4036 KiB
24Accepted2/230ms4292 KiB
25Wrong answer0/28ms4240 KiB
26Wrong answer0/218ms4448 KiB
27Wrong answer0/225ms4452 KiB
28Wrong answer0/213ms4532 KiB
29Wrong answer0/213ms4752 KiB
30Wrong answer0/219ms4748 KiB
31Accepted2/234ms5012 KiB
32Accepted2/234ms4964 KiB