141042025-01-09 19:23:18sarminParti (75 pont)cpp17Wrong answer 64/75312ms3380 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);
        }
    }

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

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base64/75
1Accepted0/01ms316 KiB
2Accepted0/086ms1844 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/42ms508 KiB
11Accepted4/41ms444 KiB
12Accepted4/42ms336 KiB
13Accepted4/42ms316 KiB
14Accepted4/42ms516 KiB
15Accepted4/485ms1844 KiB
16Accepted4/4118ms2096 KiB
17Accepted4/4157ms2340 KiB
18Accepted4/4200ms2644 KiB
19Accepted4/4252ms2868 KiB
20Time limit exceeded0/4310ms3380 KiB
21Time limit exceeded0/4312ms3380 KiB
22Accepted4/41ms316 KiB