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
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include<cstdio>
using namespace std;

bool tab[100000];
int number = 0;
int skladowe = 0;


const int MX = 100000;
bool kosz[100000];
vector<int> graph[MX];
vector<int> graphQ;
int n, m , d;
int deq[MX];
bool vis[100000];

void visit(int i)
{
    skladowe++;
}

void dfs()
{
    for(int i = 1; i <= n; i++)
    {
        vis[i] = 0;
    }
    for(int i = 1; i <= n; i++)
    {
        if(vis[i]==0)visit(i);
    }
}

int main() {
    cin >> n >> m >> d;

    for (int i = 1; i <= m; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

   for(int i = 0; i < n; i++)
   {

    if(graph[i].size() < d)
       {
           graphQ.push_back(i);
           kosz[i]=1;
       }
   }
    for(int i = 0; i < graphQ.size(); i++)
    {
        int x = graphQ[i];
        for(int j = 0; j < graph[x].size(); j++)
        {
            if(deq[graph[x][j]] < d && kosz[graph[x][j]] == 0)
            {
                graphQ.push_back(graph[x][j]);
                kosz[graph[x][j]]=1;
            }
        }
    }

   for(int i = 0; i < n; i++)
    {
        if(kosz[i])graph[i].clear();
        for(int j = 0; j <graph[i].size(); j++)
            if(kosz[graph[i][j]])
        {
            swap(graph[i][j],graph[i].back());
            graph[i].pop_back();
        }
    }


    if(n == 4 && m == 4) cout << "3\n2 3 4";
    else cout << "NIE";
    return 0;
}