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

using namespace std;

int main(int argc, char** argv)
{
	int FirstLine[3];
	
	int n, m, d;
	
	for(int i = 0; i<3; ++i)
	{
		cin>>FirstLine[i];
	}
	
	n = FirstLine[0];
	m = FirstLine[1];
	d = FirstLine[2];
	
	int Roads[m*2];
	
	for(int j = 0; j<(m*2); ++j)
	{
		cin>>Roads[j];
	}
	
	int Cities[300000];

	int tymczasowa = 0;
	
	for(int r = 0; r<(m*2); ++r)
	{
		tymczasowa = Roads[r];
		Cities[tymczasowa-1] += 1;
		tymczasowa = 0;
	}

	vector<int> GoodConnected;
	
	for(int l = 0; l<n ; ++l)
	{
		if(Cities[l] >= d)
		{
			GoodConnected.push_back(l+1);
		}
	}
	
	int HowManyUP = 0;
	int HowManyDOWN = 0;
	
	for(int y = 0; y<n; ++y)
	{
		if(Cities[y] < d)
		{
			HowManyDOWN++;
		}
		else
		{
			HowManyUP++;
		}
	}
	
	if(HowManyUP<HowManyDOWN)
	{
		cout<<"NIE"<<endl;
		return 0;
	}
	
	cout<<GoodConnected.size()<<endl;
	
	for(int y = 0; y<GoodConnected.size(); ++y)
	{
		cout<<GoodConnected[y]<<" ";
	}
	
	return 0;
}