103802024-04-01 16:42:01MagyarKendeSZLGTúra (75 pont)cpp17Wrong answer 18/7537ms4764 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;
    }

    bool running = true;
    for (int i = 1; i < N; i++) {
        int U, V;
        cin >> U >> V;

        if (running) {
            running = 0;
            if (ugly[U] && ugly[V]) {
                cout << "NEM\n2\n" << U << " " << V << "\n";
            }
            else if (uglyNeighbor[U] && ugly[V]) {
                cout << "NEM\n3\n" << uglyNeighbor[U] << " " << U << " " << V << "\n";
            }
            else if (ugly[U] && uglyNeighbor[V]) {
                cout << "NEM\n3\n" << uglyNeighbor[V] << " " << V << " " << U << "\n";
            }
            else running = 1;
        }
        
        if (ugly[U]) {
            uglyNeighbor[V] = U;
        }
        if (ugly[V]) {
            uglyNeighbor[U] = V;
        }
    }

    if (running) cout << "IGEN\n";
}

int main() {
	cin.tie(0), ios::sync_with_stdio(0);
    int T;
    cin >> T;
    while (T--) solve();
}
SubtaskSumTestVerdictTimeMemory
base18/75
1Accepted0/03ms1828 KiB
2Wrong answer0/03ms2064 KiB
3Wrong answer0/63ms2268 KiB
4Wrong answer0/34ms2500 KiB
5Wrong answer0/34ms2660 KiB
6Wrong answer0/46ms2868 KiB
7Wrong answer0/44ms3096 KiB
8Wrong answer0/44ms3300 KiB
9Wrong answer0/232ms3508 KiB
10Accepted2/232ms3728 KiB
11Wrong answer0/232ms3948 KiB
12Wrong answer0/232ms3904 KiB
13Wrong answer0/232ms4000 KiB
14Wrong answer0/332ms3996 KiB
15Accepted2/232ms4376 KiB
16Accepted2/232ms4220 KiB
17Wrong answer0/232ms4224 KiB
18Wrong answer0/232ms4316 KiB
19Wrong answer0/332ms4432 KiB
20Wrong answer0/232ms4280 KiB
21Wrong answer0/232ms4288 KiB
22Wrong answer0/334ms4568 KiB
23Accepted2/234ms4592 KiB
24Accepted2/235ms4332 KiB
25Accepted2/234ms4516 KiB
26Wrong answer0/234ms4528 KiB
27Wrong answer0/234ms4528 KiB
28Wrong answer0/234ms4616 KiB
29Accepted2/235ms4504 KiB
30Wrong answer0/235ms4764 KiB
31Accepted2/235ms4720 KiB
32Accepted2/237ms4712 KiB