72072024-01-03 14:28:02MagyarKendeSZLGHálózati biztonság (50)cpp17Accepted 50/50284ms61800 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int main() {
    speed;

    int N, M, K;
    cin >> N >> M >> K;

    vector<unordered_set<int>> g(N + 1);
    
    while (M--) {
        int U, V;
        cin >> U >> V;
        g[U].insert(V);
        g[V].insert(U);
    }

    queue<int> todo;
    for (int i = 1; i <= N; i++) {
        if (g[i].size() < K) {
            todo.push(i);
        }
    }

    while (!todo.empty()) {
        int next = todo.front(); todo.pop();

        for (int neigh : g[next]) {
            g[neigh].erase(next);
            if (g[neigh].size() < K) {
                todo.push(neigh);
            }
        }
    }

    vector<int> result;

    for (int i = 1; i <= N; i++) {
        if (g[i].size() >= K) {
            result.push_back(i);
        }
    }

    cout << result.size() << '\n';
    for (int x : result) cout << x << ' ';
    cout << '\n';
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/0145ms33244 KiB
3Accepted2/23ms3484 KiB
4Accepted2/23ms3464 KiB
5Accepted2/23ms3508 KiB
6Accepted2/23ms3600 KiB
7Accepted2/23ms3712 KiB
8Accepted2/23ms4028 KiB
9Accepted2/23ms4264 KiB
10Accepted2/28ms6136 KiB
11Accepted2/24ms4724 KiB
12Accepted2/26ms5896 KiB
13Accepted3/33ms5032 KiB
14Accepted3/37ms7500 KiB
15Accepted3/39ms9636 KiB
16Accepted3/3223ms31400 KiB
17Accepted3/38ms8948 KiB
18Accepted3/314ms15332 KiB
19Accepted3/3138ms50944 KiB
20Accepted3/3284ms61800 KiB
21Accepted3/3145ms50416 KiB
22Accepted3/33ms5040 KiB