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
#include <iostream>
#include <math.h>
using namespace std;



int miasta[200000];
int prawidlowe_miasta[200000];
//int drogi[2][200000];

int main()
{
	int liczba_miast;
	int liczba_drog;
	int minimalna_liczba_bezposrednich_drog;
	int i,miasto1,miasto2,ile_miast_prawidlowych=0;
	
	cin >> liczba_miast;

	// zerujemy tablicę miast
	for(i=0;i<liczba_miast;i++)
	{
		miasta[i]=0;
	}

	cin >> liczba_drog;
	cin >> minimalna_liczba_bezposrednich_drog;

	for(i=0;i<liczba_drog;i++)
	{
		cin >> miasto1;
		cin >> miasto2;
		miasta[miasto1]++;
		miasta[miasto2]++;
	}

	for(i=1;i<=liczba_miast;i++)
	{
		if(miasta[i]>=minimalna_liczba_bezposrednich_drog)
		{
			prawidlowe_miasta[ile_miast_prawidlowych]=i;
			ile_miast_prawidlowych++;
		}
	}

	if(ile_miast_prawidlowych>1)
	{
		cout <<ile_miast_prawidlowych<<std::endl;
		for(i=0;i<ile_miast_prawidlowych;i++)
		{
			cout << prawidlowe_miasta[i] <<" ";
		}
	}
	else
	{
		cout <<"NIE"<<std::endl;
	}
	return 0;
}