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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>

using namespace std;

const int INF = 2020020;
const int N = 200005;

vector<int> V[N];
queue<int> Q;
int degs[N];
int dels[N];
int vis[N];
int mc[N];

int main()
{
    int n,m,dd;
    scanf("%d%d%d",&n,&m,&dd);
    int a,b;
    for(int i=0;i<m;++i)
    {
        scanf("%d%d",&a,&b);
        --a;--b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    for(int i=0;i<n;++i)
        degs[i]=V[i].size();

    for(int i=0;i<n;++i)
        if (degs[i]<dd) {
            Q.push(i);
            dels[i]=1;
        }

    while(!Q.empty()) {
        int a = Q.front();
        Q.pop();
        for(int i=0;i<V[a].size();++i) {
            int b=V[a][i];
            if (degs[b]==dd) {
                Q.push(b);
                dels[b]=1;
            }
            --degs[b];
        }
    }

    int col=0;
    for(int i=0;i<n;++i){
        if ((!vis[i])&&(!dels[i])) {
            ++col;
            Q.push(i);
            vis[i]=col;
            int s=0;
            while(!Q.empty()) {
                int f=Q.front();
                Q.pop();
                for(int j=0;j<V[f].size();++j){
                    if ((!vis[V[f][j]])&&(!dels[V[f][j]])) {
                        vis[V[f][j]]=col;
                        Q.push(V[f][j]);
                    }
                }
            }
        }
    }

    int mx=0;
    int gc;
    for(int i=0;i<=n;++i)
        ++mc[vis[i]];
    for(int i=1;i<=n;++i) {
        if(mx<mc[i]) {
            mx=mc[i];
            gc=i;
        }
    }

    if (!mx) {
        printf("NIE\n");
        return 0;
    }

    printf("%d\n",mx);
    for(int i=0;i<n;++i)
        if (vis[i]==gc)
            printf("%d ",i+1);


    return 0;
}