141352025-01-09 21:11:18sarminParti (75 pont)cpp17Wrong answer 72/7539ms4916 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]++;
    }

    list<int> living;
    for (int i = 0; i < n; i++) living.push_back(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]--;
            i = living.erase(i);
        }
    }

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

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/01ms316 KiB
2Accepted0/019ms2612 KiB
3Accepted3/31ms512 KiB
4Accepted3/31ms508 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/42ms316 KiB
11Accepted4/41ms508 KiB
12Accepted4/41ms316 KiB
13Accepted4/42ms316 KiB
14Accepted4/42ms564 KiB
15Accepted4/419ms2584 KiB
16Accepted4/424ms3116 KiB
17Accepted4/428ms3568 KiB
18Accepted4/432ms3936 KiB
19Accepted4/435ms4308 KiB
20Accepted4/439ms4736 KiB
21Accepted4/439ms4916 KiB
22Accepted4/41ms316 KiB