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
#include<bits/stdc++.h>

using namespace std;

const int N = 2e5+77;
int deg[N];
vector<int> G[N];

vector<int> resv;
vector<int> tmpv;
void dfs(int v) {
	tmpv.push_back(v);
	deg[v]*=(-1);
	for(int w : G[v]) {
		if(deg[w] <= 0) continue;
		dfs(w);
	}
}

bool biore[N];

int main () {
	vector<int> X;
	int n,m,d;
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> d;
	int a,b;
	for(int i=0;i<m;i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
		deg[a]++;
		deg[b]++;
	}
	for(int i=1;i<=n;i++) if(deg[i] < d){
		X.push_back(i);
	}
	for(int i=0;i<(int)X.size();i++) {
		int v = X[i];
		deg[v] = 0;
		for(int w : G[v]) {
			deg[w]--;
			if(deg[w] == d-1) {
				X.push_back(w);
			}
		}
	}
	for(int i=1;i<=n;i++) if(deg[i] >= 1) {
		tmpv.clear();
		dfs(i);
		if(tmpv.size() > resv.size()) resv = tmpv;
	}
	for(int i=0;i<resv.size();i++) {
		biore[resv[i]] = 1;
	}
	if(resv.size() == 0) cout << "NIE\n";
	else {
		cout << resv.size() << "\n";
		for(int i=1;i<=n;i++) if(biore[i]) cout << i << " ";
		cout << "\n";
	}
}