149332025-02-08 15:04:12miszorimarciParti (75 pont)cpp17Wrong answer 72/7587ms6452 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
    vector<int>ind(n);
    vector<vector<int>>g(n);
    vector<bool>participants(n, 1);
    for(int i  = 0; i < n; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        g[i].push_back(a);
        g[i].push_back(b);
        ind[a]++;
        ind[b]++;
    }
    bool removing = true;
    int ans = n;
    while(removing)
    {
        removing = false;
        for(int i = 0; i < n; i++)
        {
            if(ind[i] < 2 && participants[i])
            {
                removing = 1;
                participants[i] = 0;
                for(int p : g[i])ind[p]--;
                ans--;
            }
        }
    }
    cout << ans << "\n";
    for(int i = 0; i < n; i++)
    {
        if(participants[i])cout << i + 1 << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/01ms316 KiB
2Accepted0/045ms3240 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms504 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/42ms316 KiB
10Accepted4/42ms316 KiB
11Accepted4/42ms508 KiB
12Accepted4/42ms484 KiB
13Accepted4/43ms564 KiB
14Accepted4/44ms564 KiB
15Accepted4/443ms3276 KiB
16Accepted4/452ms4052 KiB
17Accepted4/461ms4660 KiB
18Accepted4/471ms5108 KiB
19Accepted4/479ms5680 KiB
20Accepted4/487ms6340 KiB
21Accepted4/486ms6452 KiB
22Accepted4/41ms316 KiB