94052024-02-21 13:01:46Vkrisztian01Hálózati biztonság (50)cpp17Accepted 50/50160ms19760 KiB
#include <iostream>
#include<vector>

using namespace std;

int n,m,k,a,b,legjobb=0;
vector<vector<int> > g;
vector<int>fokszam;
vector<vector<int> > komponensek;
vector<int>ki;

void dfs1(int node)
{
    --fokszam[node];
    if(fokszam[node]>=k) return;
    fokszam[node]=-1;
    for(auto to:g[node])
    {
        if(fokszam[to]==-1) continue;
        dfs1(to);
    }
}

int main()
{
    cin>>n>>m>>k;
    g.resize(n+1);
    fokszam.assign(n+1,0);
    while(m--)
    {
        cin>>a>>b;
        ++fokszam[a];
        ++fokszam[b];
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=1;i<=n;i++) if(fokszam[i]!=-1 && fokszam[i]<k) dfs1(i);
    for(int i=1;i<=n;i++) if(fokszam[i]!=-1) ki.push_back(i);
    cout<<ki.size()<<endl;
    for(auto x:ki) cout<<x<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1896 KiB
2Accepted0/086ms10432 KiB
3Accepted2/23ms2264 KiB
4Accepted2/23ms2348 KiB
5Accepted2/23ms2480 KiB
6Accepted2/23ms2712 KiB
7Accepted2/23ms2836 KiB
8Accepted2/23ms3028 KiB
9Accepted2/23ms3208 KiB
10Accepted2/28ms3876 KiB
11Accepted2/24ms3596 KiB
12Accepted2/26ms4088 KiB
13Accepted3/33ms3932 KiB
14Accepted3/37ms4420 KiB
15Accepted3/38ms5224 KiB
16Accepted3/381ms9880 KiB
17Accepted3/38ms4488 KiB
18Accepted3/312ms7164 KiB
19Accepted3/396ms16220 KiB
20Accepted3/3160ms19760 KiB
21Accepted3/3101ms16508 KiB
22Accepted3/33ms3724 KiB