250632026-02-17 18:16:14sscrazyyParti (75 pont)cpp17Wrong answer 72/7579ms1708 KiB
// Party Invitations — Iterative Elimination O(N²)
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> wish(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> wish[i].first >> wish[i].second;

    vector<bool> invited(n + 1, true);
    bool changed = true;

    while (changed) {
        changed = false;
        // Count supporters for each person
        vector<int> support(n + 1, 0);
        for (int i = 1; i <= n; i++) {
            if (!invited[i]) continue;
            support[wish[i].first]++;
            support[wish[i].second]++;
        }
        // Remove anyone with < 2 supporters
        for (int i = 1; i <= n; i++) {
            if (invited[i] && support[i] < 2) {
                invited[i] = false;
                changed = true;
            }
        }
    }

    vector<int> result;
    for (int i = 1; i <= n; i++)
        if (invited[i]) result.push_back(i);

    cout << result.size() << endl;
    for (int i = 0; i < (int)result.size(); i++)
        cout << result[i] << (i+1 < (int)result.size() ? " " : "\n");
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/01ms316 KiB
2Accepted0/039ms1132 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Wrong answer0/31ms384 KiB
6Accepted3/31ms360 KiB
7Accepted3/31ms528 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/42ms388 KiB
11Accepted4/42ms316 KiB
12Accepted4/43ms556 KiB
13Accepted4/43ms316 KiB
14Accepted4/44ms316 KiB
15Accepted4/439ms1124 KiB
16Accepted4/446ms1160 KiB
17Accepted4/454ms1212 KiB
18Accepted4/463ms1488 KiB
19Accepted4/471ms1528 KiB
20Accepted4/478ms1708 KiB
21Accepted4/479ms1708 KiB
22Accepted4/41ms316 KiB