93412024-02-20 16:46:08PallanekPéterHálózati biztonság (50)cpp17Accepted 50/50160ms18232 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> graf(n+1);
    vector<int> db(n+1, 0);
    vector<bool> safe(n+1, true);
    for (int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        graf[u].push_back(v);
        graf[v].push_back(u);
        db[u]++;db[v]++;
    }
    queue<int> Q;
    for (int i=1;i<=n;i++){
        if (db[i]<k){
            Q.push(i);
        }
    }
    int ns = 0;
    while (!Q.empty()){
        int u = Q.front();
        Q.pop();
        if (!safe[u]) continue;
        safe[u] = false;
        ns++;
        for (int v : graf[u]){
            db[v]--;
            if (safe[v] and db[v] < k){
                Q.push(v);
            }
        }
    }
    cout << n - ns << "\n";
    for (int i=1; i<=n; i++){
        if (safe[i]) cout << i << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/086ms9652 KiB
3Accepted2/23ms2088 KiB
4Accepted2/23ms2220 KiB
5Accepted2/23ms2460 KiB
6Accepted2/23ms2668 KiB
7Accepted2/23ms2764 KiB
8Accepted2/23ms2900 KiB
9Accepted2/23ms2948 KiB
10Accepted2/28ms3508 KiB
11Accepted2/24ms3720 KiB
12Accepted2/27ms4236 KiB
13Accepted3/33ms4032 KiB
14Accepted3/37ms4612 KiB
15Accepted3/38ms5688 KiB
16Accepted3/381ms9316 KiB
17Accepted3/38ms4508 KiB
18Accepted3/312ms7604 KiB
19Accepted3/393ms15956 KiB
20Accepted3/3160ms18232 KiB
21Accepted3/3112ms16644 KiB
22Accepted3/33ms4324 KiB