8742022-01-21 22:22:31Valaki2Hálózati biztonság (50)cpp14Elfogadva 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/04ms6528 KiB
2Elfogadva0/048ms12392 KiB
3Elfogadva2/24ms7664 KiB
4Elfogadva2/24ms7664 KiB
5Elfogadva2/23ms7680 KiB
6Elfogadva2/24ms7672 KiB
7Elfogadva2/24ms7688 KiB
8Elfogadva2/23ms7700 KiB
9Elfogadva2/23ms7696 KiB
10Elfogadva2/26ms8124 KiB
11Elfogadva2/24ms7936 KiB
12Elfogadva2/26ms8168 KiB
13Elfogadva3/34ms8028 KiB
14Elfogadva3/36ms8528 KiB
15Elfogadva3/37ms8892 KiB
16Elfogadva3/345ms13024 KiB
17Elfogadva3/36ms9736 KiB
18Elfogadva3/38ms10824 KiB
19Elfogadva3/364ms17756 KiB
20Elfogadva3/3105ms21544 KiB
21Elfogadva3/370ms21464 KiB
22Elfogadva3/33ms13792 KiB