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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int miasta;
    cin >> miasta;
    int drogi;
    cin >> drogi;
    int d;
    cin >> d;
    int temp1, temp2;
    vector < vector <bool> > polaczenia(miasta, vector<bool>(0));
    vector <int> iledrog(miasta);
    for (int i=0; i<drogi; ++i)
    {
        cin >> temp1 >> temp2;
        polaczenia[temp1-1].push_back(temp2-1);
        ++iledrog[temp1-1];
        polaczenia[temp2-1].push_back(temp1-1);
        ++iledrog[temp2-1];
    }
    vector <int> mozliwe(0);
    for (int i=0; i<miasta; ++i)
    {
        if (iledrog[i] < d)
            for (int j=0; j<polaczenia[i].size(); ++j)
            {
                --iledrog[ polaczenia[i][j] ];
            }
    }
    for (int i=0; i<miasta; ++i)
    {
        if(iledrog[i] >= d)
            mozliwe.push_back(i);
    }
    if (mozliwe.size() == 0)
    {
        cout << "NIE";
        return 0;
    }
    cout << mozliwe.size() << endl;
    for (int i=0; i<mozliwe.size(); ++i)
        cout << mozliwe[i]+1 << " ";
    return 0;
}