103812024-04-01 16:51:58MagyarKendeSZLGTúra (75 pont)cpp17Elfogadva 75/7535ms4608 KiB
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<bool> ugly(N + 1);
    vector<int> 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();
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base75/75
1Elfogadva0/03ms1696 KiB
2Elfogadva0/03ms1932 KiB
3Elfogadva6/63ms2144 KiB
4Elfogadva3/34ms2508 KiB
5Elfogadva3/34ms2432 KiB
6Elfogadva4/44ms2436 KiB
7Elfogadva4/44ms2564 KiB
8Elfogadva4/44ms2628 KiB
9Elfogadva2/228ms2912 KiB
10Elfogadva2/229ms3128 KiB
11Elfogadva2/229ms3296 KiB
12Elfogadva2/229ms3508 KiB
13Elfogadva2/229ms3820 KiB
14Elfogadva3/329ms3932 KiB
15Elfogadva2/229ms3892 KiB
16Elfogadva2/229ms3944 KiB
17Elfogadva2/229ms4008 KiB
18Elfogadva2/229ms4000 KiB
19Elfogadva3/329ms3948 KiB
20Elfogadva2/230ms3884 KiB
21Elfogadva2/230ms3940 KiB
22Elfogadva3/332ms3888 KiB
23Elfogadva2/232ms4536 KiB
24Elfogadva2/232ms4536 KiB
25Elfogadva2/232ms4224 KiB
26Elfogadva2/232ms4224 KiB
27Elfogadva2/232ms4224 KiB
28Elfogadva2/230ms4288 KiB
29Elfogadva2/234ms4300 KiB
30Elfogadva2/232ms4372 KiB
31Elfogadva2/234ms4292 KiB
32Elfogadva2/235ms4608 KiB