141282025-01-09 20:59:35sarminParti (75 pont)cpp17Wrong answer 64/75310ms2124 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;
        auto i = living.begin();
        while (i != living.end()) {
            if (a[*i] >= 2) {
                i++;
                continue;
            }
            volt = true;
            a[v[*i].first]--; a[v[*i].second]--;
            living.erase(i);
        }
    }

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

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base64/75
1Accepted0/01ms316 KiB
2Accepted0/085ms1276 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/42ms316 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms316 KiB
13Accepted4/42ms316 KiB
14Accepted4/42ms540 KiB
15Accepted4/483ms1216 KiB
16Accepted4/4116ms1396 KiB
17Accepted4/4156ms1588 KiB
18Accepted4/4197ms1844 KiB
19Accepted4/4250ms2000 KiB
20Time limit exceeded0/4310ms2124 KiB
21Time limit exceeded0/4310ms2124 KiB
22Accepted4/41ms316 KiB