78922024-01-11 18:15:36AblablablaTúra (75 pont)cpp17Accepted 75/7564ms16348 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        int n;
        cin >> n;

        vector<bool> jo(n, 0);
        for(int i = 0; i < n; i++){
            int a;
            cin >> a;

            jo[i] = (a == 1);
        }

        vector<vector<int>> csucsok(n, vector<int>());
        for(int i = 0; i < n - 1; i++){
            int a, b;
            cin >> a >> b;
            a--; b--;

            csucsok[a].push_back(b);
            csucsok[b].push_back(a);
        }

        bool rossz = 0;
        for(int i = 0; i < n; i++){
            if(jo[i]) continue;

            for(int x : csucsok[i]){
                if(!jo[x]){
                    cout << "NEM\n";
                    cout << "2\n";
                    cout << i + 1 << " " << x + 1 << "\n";
                    rossz = 1;
                } else{
                    for(int y : csucsok[x]){
                        if(!jo[y] && y != i){
                            cout << "NEM\n";
                            cout << "3\n";
                            cout << i + 1 << " " << x + 1 << " " << y + 1 << "\n";
                            rossz = 1;
                        }

                        if(rossz){
                            break;
                        }
                    }
                }

                if(rossz){
                    break;
                }
            }

            if(rossz){
                break;
            }
        }

        if(!rossz){
            cout << "IGEN\n";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1828 KiB
2Accepted0/03ms2064 KiB
3Accepted6/63ms2232 KiB
4Accepted3/36ms2508 KiB
5Accepted3/36ms2732 KiB
6Accepted4/46ms2688 KiB
7Accepted4/47ms2944 KiB
8Accepted4/47ms3152 KiB
9Accepted2/243ms4388 KiB
10Accepted2/245ms4448 KiB
11Accepted2/243ms4704 KiB
12Accepted2/243ms4656 KiB
13Accepted2/243ms4976 KiB
14Accepted3/343ms4968 KiB
15Accepted2/245ms5020 KiB
16Accepted2/243ms5080 KiB
17Accepted2/243ms5292 KiB
18Accepted2/241ms5484 KiB
19Accepted3/341ms5436 KiB
20Accepted2/241ms5440 KiB
21Accepted2/243ms5432 KiB
22Accepted3/346ms5400 KiB
23Accepted2/248ms16348 KiB
24Accepted2/264ms15296 KiB
25Accepted2/248ms10076 KiB
26Accepted2/246ms10704 KiB
27Accepted2/250ms10476 KiB
28Accepted2/246ms10796 KiB
29Accepted2/250ms10288 KiB
30Accepted2/246ms10796 KiB
31Accepted2/252ms10624 KiB
32Accepted2/254ms10284 KiB