1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
vector<int> tos[N];
bool vis[N];
int n,m,d,c=0;
int T[N];
vector<int> vec,wyn;
queue<int> q;
void dfs(int v)
{
    if (vis[v])return;
    vec.push_back(v);
    vis[v]=1;
    for(int i=0; i<tos[v].size(); i++)
    {
        dfs(tos[v][i]);
    }
    c++;
}

int main()
{
    cout.sync_with_stdio(false);
    cin>> n >> m >>d;
    int a,b;
    for (int i=0; i<m; i++)
    {
        cin >> a >> b;
        tos[b-1].push_back(a-1);
        tos[a-1].push_back(b-1);
        T[a-1]++;T[b-1]++;
    }
    for(int i=0;i<n;i++)if(T[i]<d)q.push(i);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        if(vis[x]==1)continue;
        for(int i=0;i<tos[x].size();i++)
        {
            T[tos[x][i]]--;
            if(T[tos[x][i]]<d)q.push(tos[x][i]);
        }
        vis[x]=1;
    }
    int maxc=0;
    for(int i=0;i<n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
            if(c>maxc){maxc=c;wyn.clear();wyn=vec;}
            c=0;
            vec.clear();
        }
    }
    sort(wyn.begin(),wyn.end());
    if(maxc!=0){cout << maxc <<"\n";
    for(int i=0;i<wyn.size();i++)cout << wyn[i]+1 << " ";}
    else(cout << "NIE");
    return 0;
}