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
#include <iostream>
#include <vector>

using namespace std;

struct punkt{
    int c;
    vector<int> v;
};

int n, m, a, b, d, mx, ctr;
punkt g[200003], w;
bool vis[200004], flag;
vector<int> sq, sqt;

void dfs_reduce(int v){
    vis[v] = true;
    for(int i = 0; i < g[v].v.size(); ++i){
        w = g[g[v].v[i]];
        w.c--;
        g[g[v].v[i]].c--;
        if(w.c < d and !vis[g[v].v[i]]) dfs_reduce(g[v].v[i]);
    }
    return;
}

void dfs_counter(int v){
	vis[v] = true;
	sqt.push_back(v);
	ctr++;
	for(int i = 0; i < g[v].v.size(); ++i){
        w = g[g[v].v[i]];
        if(w.c >= d and !vis[g[v].v[i]]) dfs_counter(g[v].v[i]);
    }
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
	cin >> n >> m >> d;
    for(int i = 0; i < m; ++i){
        cin >> a >> b;
        g[a].v.push_back(b);
        g[b].v.push_back(a);
    }
    for(int i = 1; i <= n; ++i){
        g[i].c = g[i].v.size();
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i] and g[i].c < d)
		dfs_reduce(i); 
    } 
	for(int i = 1; i <= n; ++i){
		vis[i] = 0;
	}
	for(int i = 1; i <= n; ++i){
		if(!vis[i] and g[i].c >= d){
			ctr = 0;
			dfs_counter(i);
			if(ctr > mx){
				mx = ctr;
				sq = sqt;
				sqt.clear();
			}
		}
	}
	if(mx == 0){
		cout << "NIE" << endl;
		return 0;
	}
	cout << mx << endl;
	for(int i = 0; i < sq.size(); ++i){
		cout << sq[i] << " ";
	}
	cout << endl;
    return 0;
}