141262025-01-09 20:51:02sarminParti (75 pont)cpp17Runtime error 27/75308ms2052 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n; cin >> n;
	vector<pair<int, int>> v(n);
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        v[i].first--; v[i].second--;
        a[v[i].first]++; a[v[i].second]++;
    }

    vector<int> living(n);
    for (int i = 0; i < n; i++) living[i] = i;
    bool volt = true;
    while (living.size() && volt) {
        volt = false;
        int i = 0;
        while (i < (int) living.size()) {
            if (a[living[i]] >= 2) {
                i++;
                continue;
            }
            volt = true;
            a[v[living[i]].first]--; a[v[living[i]].second]--;
            living.erase(living.begin() + i);
            i--;
        }
    }

    cout << living.size() << "\n";
    for (int x : living) cout << x+1 << " ";

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base27/75
1Accepted0/01ms512 KiB
2Runtime error0/074ms1076 KiB
3Runtime error0/31ms512 KiB
4Accepted3/31ms316 KiB
5Runtime error0/33ms316 KiB
6Runtime error0/33ms444 KiB
7Runtime error0/33ms504 KiB
8Runtime error0/41ms316 KiB
9Runtime error0/43ms316 KiB
10Accepted4/41ms316 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms316 KiB
13Runtime error0/42ms316 KiB
14Accepted4/42ms316 KiB
15Accepted4/483ms1216 KiB
16Runtime error0/414ms1344 KiB
17Runtime error0/416ms1516 KiB
18Runtime error0/417ms1588 KiB
19Runtime error0/419ms1760 KiB
20Time limit exceeded0/4308ms2052 KiB
21Runtime error0/421ms1844 KiB
22Accepted4/41ms316 KiB