8742022-01-21 22:22:31Valaki2Hálózati biztonság (50)cpp14Accepted 50/50105ms21544 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e5;

int n, m, k;
vector<int> g[maxn + 1];
int degree[maxn + 1];
bool removed[maxn + 1];
queue<int> q;

void rem(int x) {
    for(int y : g[x]) {
        degree[y]--;
        if(degree[y] < k && !removed[y]) {
            removed[y] = true;
            q.push(y);
        }
    }
}

void solve() {
    cin >> n >> m >> k;
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
        degree[a]++;
        degree[b]++;
    }
    for(int i = 1; i <= n; i++) {
        if(degree[i] < k) {
            removed[i] = true;
            q.push(i);
        }
    }
    while(!q.empty()) {
        int cur = q.front();
        q.pop();
        rem(cur);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(!removed[i]) {
            cnt++;
        }
    }
    cout << cnt << "\n";
    for(int i = 1; i <= n; i++) {
        if(!removed[i]) {
            cout << i << " ";
        }
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/04ms6528 KiB
2Accepted0/048ms12392 KiB
3Accepted2/24ms7664 KiB
4Accepted2/24ms7664 KiB
5Accepted2/23ms7680 KiB
6Accepted2/24ms7672 KiB
7Accepted2/24ms7688 KiB
8Accepted2/23ms7700 KiB
9Accepted2/23ms7696 KiB
10Accepted2/26ms8124 KiB
11Accepted2/24ms7936 KiB
12Accepted2/26ms8168 KiB
13Accepted3/34ms8028 KiB
14Accepted3/36ms8528 KiB
15Accepted3/37ms8892 KiB
16Accepted3/345ms13024 KiB
17Accepted3/36ms9736 KiB
18Accepted3/38ms10824 KiB
19Accepted3/364ms17756 KiB
20Accepted3/3105ms21544 KiB
21Accepted3/370ms21464 KiB
22Accepted3/33ms13792 KiB