10122022-02-23 13:02:23rmlanHálózati biztonság (50)cpp14Accepted 50/50192ms30828 KiB
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<int> > g(n+1);
    vector<int> fsz(n+1);
    for(int i = 0; i <= n; i++) fsz[i]=0;
    for(int i = 0; i < m; i++){
        int u,v;
        cin >> u >> v;
        fsz[u]++;
        fsz[v]++;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    queue<int> q;
    set<int> s;
    bool vt[n+1]={0};
    int ans=n;
    for(int i = 1; i <= n; i++){
        s.insert(i);
        if(fsz[i] < k){q.push(i);ans--;vt[i]=1;}
    }
    while(!q.empty()){
        int v = q.front();
        s.erase(v);
        q.pop();
        for(int i = 0; i < g[v].size(); i++){
            int u =g[v][i];
            if(vt[u]) continue;
            if(--fsz[u] < k){
                vt[u]=1;
                q.push(u);
                ans--;
            }
        }
    }
    cout << ans<<endl;
    set<int>::iterator it;

    for(it = s.begin(); it!=s.end(); it++){
        cout << *it << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1792 KiB
2Accepted0/093ms14712 KiB
3Accepted2/21ms2992 KiB
4Accepted2/21ms3000 KiB
5Accepted2/21ms3008 KiB
6Accepted2/21ms3008 KiB
7Accepted2/21ms3028 KiB
8Accepted2/21ms3048 KiB
9Accepted2/21ms3052 KiB
10Accepted2/26ms3476 KiB
11Accepted2/22ms3396 KiB
12Accepted2/24ms3824 KiB
13Accepted3/32ms3684 KiB
14Accepted3/39ms5132 KiB
15Accepted3/310ms6804 KiB
16Accepted3/386ms12188 KiB
17Accepted3/37ms5856 KiB
18Accepted3/320ms12868 KiB
19Accepted3/3125ms27024 KiB
20Accepted3/3192ms30828 KiB
21Accepted3/3129ms30580 KiB
22Accepted3/31ms9124 KiB