77422024-01-10 21:34:36AblablablaParti (75 pont)cpp17Wrong answer 4/75101ms15820 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<vector<int>> csucsok(n, vector<int>());
    vector<int> befok(n, 0);

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

        csucsok[i].push_back(a);
        csucsok[i].push_back(b);
        befok[a]++;
        befok[b]++;
    }

    queue<int> bejar;
    vector<bool> bejart(n, 0);

    for(int i = 0; i < n; i++){
        if(befok[i] >= 2) continue;

        bejar.push(i);
    }

    while(!bejar.empty()){
        int akt = bejar.front();
        bejar.pop();


        if(bejart[akt]) continue;

        cout << akt << "\n";
        bejart[akt] = 1;

        for(int x : csucsok[akt]){
            befok[x]--;

            if(befok[x] < 2){
                bejar.push(x);
            }
        }
    }

    int valasz = 0;
    for(int i = 0; i < n; i++){
        valasz += !bejart[i];
    }

    cout << valasz << "\n";
    for(int i = 0; i < n; i++){
        if(!bejart[i]){
            cout << i + 1 << " ";
        }
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base4/75
1Wrong answer0/03ms1816 KiB
2Wrong answer0/050ms8612 KiB
3Wrong answer0/33ms2520 KiB
4Wrong answer0/33ms2672 KiB
5Wrong answer0/33ms2796 KiB
6Wrong answer0/33ms2928 KiB
7Wrong answer0/33ms3156 KiB
8Wrong answer0/43ms3248 KiB
9Wrong answer0/43ms3276 KiB
10Wrong answer0/44ms3736 KiB
11Wrong answer0/43ms3328 KiB
12Wrong answer0/44ms3516 KiB
13Wrong answer0/44ms3832 KiB
14Wrong answer0/46ms3836 KiB
15Wrong answer0/450ms9368 KiB
16Wrong answer0/459ms10792 KiB
17Wrong answer0/468ms11844 KiB
18Wrong answer0/482ms12964 KiB
19Wrong answer0/489ms14392 KiB
20Wrong answer0/4101ms15820 KiB
21Wrong answer0/498ms15776 KiB
22Accepted4/43ms3904 KiB