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
#include <stdio.h>
#include <vector>

using namespace std;

vector <int> paths[200001];
int degree[200001];
int count[200001];
int component[200001];
int cmpn = 0;
bool deleted[200001];
int ans[200001];
int ansc, ansn;

int n, m, d;

void dfs1(int v)
{
	deleted[v] = true;
	for(unsigned int i = 0; i < paths[v].size(); ++i)
	{
		degree[paths[v][i]] -= 1;
		if(degree[paths[v][i]] < d && !deleted[paths[v][i]])
			dfs1(paths[v][i]);
	}
}

void dfs2(int v)
{
	component[v] = cmpn;
	ans[cmpn] += 1;
	for(unsigned int i = 0; i < paths[v].size(); ++i)
	{
		if(!deleted[paths[v][i]] && component[paths[v][i]] == 0) dfs2(paths[v][i]);
	}
}

int main()
{	
	scanf("%i %i %i", &n, &m, &d);
	
	for(int i = 0; i < m; ++i)
	{
		int tmp1, tmp2; 
		scanf("%i %i", &tmp1, &tmp2);
		
		paths[tmp1].push_back(tmp2);
		paths[tmp2].push_back(tmp1);
		degree[tmp1] += 1;
		degree[tmp2] += 1;
	}
	
	for(int i = 1; i <= n; ++i)
	{
		if(!deleted[i] && degree[i] < d) dfs1(i); 
	}
	
	for(int i = 1; i <= n; ++i)
	{
		if(!deleted[i] && component[i] == 0)
		{
			++cmpn;
			dfs2(i);
			if(ans[cmpn] > ansc)
			{
				ansc = ans[cmpn];
				ansn = cmpn;
			}
		}
	}
	
	if(ansn == 0) printf("NIE\n");
	else
	{
		printf("%i\n", ansc);
		for(int i = 1; i <= n; ++i)
		{
			if(component[i] == ansn)
			{
				--ansc;
				if(ansc != 0) printf("%i ", i);
				else printf("%i\n", i);
			}
		}
	}
	
	return 0;
}