141272025-01-09 20:51:54sarminParti (75 pont)cpp17Wrong answer 64/75310ms2100 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);
            if (i - 1 >= 0) i--;
        }
    }

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

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base64/75
1Accepted0/01ms316 KiB
2Accepted0/083ms1332 KiB
3Accepted3/31ms508 KiB
4Accepted3/31ms508 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/42ms316 KiB
11Accepted4/41ms388 KiB
12Accepted4/42ms316 KiB
13Accepted4/42ms316 KiB
14Accepted4/42ms316 KiB
15Accepted4/483ms1220 KiB
16Accepted4/4115ms1380 KiB
17Accepted4/4156ms1528 KiB
18Accepted4/4197ms1844 KiB
19Accepted4/4250ms1844 KiB
20Time limit exceeded0/4308ms2000 KiB
21Time limit exceeded0/4310ms2100 KiB
22Accepted4/41ms316 KiB