233632026-01-20 18:51:46xxxHálózati biztonság (50)cpp17Accepted 50/50165ms7324 KiB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int> > adj;
vector<bool> jo;
vector<int> be;
int n, m, k;

int main() {
    cin >> n >> m >> k;

    adj.assign(n+1, {});
    jo.assign(n+1, 1);
    be.assign(n+1, 0);

    for(int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        be[x]++, be[y]++;
    }

    //cout << endl;

    queue<int> q;
    for(int i = 1; i <= n; i++) {
        //cout << i << ": " << be[i] << '\n';
        if (be[i] < k) {
            q.push(i);
            jo[i] = 0;
        }
    }

    while(!q.empty()) {
        //cout << q.front() << ' ';
        int v = q.front();
        q.pop();
        jo[v] = 0;
        if(be[v]==0) continue;
        be[v] = 0;



        for(int u : adj[v]) {
            if(be[u]>0) be[u]--;
            if(be[u] < k && be[u]!=0) {
                q.push(u);
            }
        }
    }

    vector<int> ans;

    for(int i = 1; i <= n; i++) {
        if(jo[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(int x : ans) cout << x << ' ';

}

/*
8 12 3
8 7
7 3
4 3
8 5
6 5
3 1
2 1
7 1
2 7
2 3
4 6
4 7
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/093ms4040 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms404 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms560 KiB
10Accepted2/26ms396 KiB
11Accepted2/22ms316 KiB
12Accepted2/24ms564 KiB
13Accepted3/32ms508 KiB
14Accepted3/34ms828 KiB
15Accepted3/38ms1336 KiB
16Accepted3/383ms3200 KiB
17Accepted3/36ms820 KiB
18Accepted3/310ms2236 KiB
19Accepted3/397ms6356 KiB
20Accepted3/3165ms7324 KiB
21Accepted3/3104ms6356 KiB
22Accepted3/31ms316 KiB