78902024-01-11 18:11:29AblablablaTúra (75 pont)cpp17Wrong answer 0/75111ms18872 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    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 << "NO\n";
                    cout << "2\n";
                    cout << i + 1 << " " << x << "\n";
                    rossz = 1;
                } else{
                    for(int y : csucsok[x]){
                        if(!jo[y] && y != i){
                            cout << "NO\n";
                            cout << "3\n";
                            cout << i + 1 << " " << x << " " << y << "\n";
                            rossz = 1;
                        }

                        if(rossz){
                            break;
                        }
                    }
                }

                if(rossz){
                    break;
                }
            }

            if(rossz){
                break;
            }
        }

        if(!rossz){
            cout << "YES\n";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/03ms1996 KiB
2Wrong answer0/03ms2016 KiB
3Wrong answer0/63ms2260 KiB
4Wrong answer0/310ms2660 KiB
5Wrong answer0/310ms2920 KiB
6Wrong answer0/410ms3132 KiB
7Wrong answer0/410ms3312 KiB
8Wrong answer0/410ms3620 KiB
9Wrong answer0/290ms6120 KiB
10Wrong answer0/292ms6924 KiB
11Wrong answer0/292ms7780 KiB
12Wrong answer0/290ms7848 KiB
13Wrong answer0/292ms8088 KiB
14Wrong answer0/390ms8092 KiB
15Wrong answer0/290ms8352 KiB
16Wrong answer0/292ms8300 KiB
17Wrong answer0/290ms8384 KiB
18Wrong answer0/289ms8652 KiB
19Wrong answer0/387ms8552 KiB
20Wrong answer0/287ms8516 KiB
21Wrong answer0/290ms8552 KiB
22Wrong answer0/393ms8540 KiB
23Wrong answer0/2100ms18872 KiB
24Wrong answer0/2104ms18140 KiB
25Wrong answer0/2103ms12884 KiB
26Wrong answer0/298ms13340 KiB
27Wrong answer0/2101ms12808 KiB
28Wrong answer0/297ms13440 KiB
29Wrong answer0/2104ms13132 KiB
30Wrong answer0/298ms13592 KiB
31Wrong answer0/2104ms13520 KiB
32Wrong answer0/2111ms13432 KiB