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

const int MAX_N = 200009;

int n, m, d, g;
std::vector<int> adj[MAX_N];
int sadj[MAX_N];
int v[MAX_N];
int c;

void check_rem(int i) {
  if (sadj[i] < d) {
    v[i] = sadj[i] = -1;
    for (int j : adj[i]) {
      if (sadj[j] != -1) {
	--sadj[j];
	check_rem(j);
      }
    }
  }
}

void dfs(int i) {
  v[i] = g;
  ++c;
  for (int j : adj[i]) {
    if (v[j] == 0) {
      dfs(j);
    }
  }
}

int main() {
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a-1].push_back(b-1);
    ++sadj[a-1];
    adj[b-1].push_back(a-1);
    ++sadj[b-1];
  }
  for (int i = 0; i < n; ++i) {
    if (sadj[i] != -1) {
      check_rem(i);
    }
  }
  int max = -1, maxc = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] == 0) {
      c = 0;
      ++g;
      dfs(i);
      if (c > maxc) { 
	max = g;
	maxc = c;
      }
    }
  }
  if (max == -1) {
    printf("NIE\n");
    return 0;
  }
  int i;
  printf("%d\n", maxc);
  for (i = 0; i < n; ++i) {
    if (v[i] == max) {
      printf("%d", i+1);
      break;
    }
  }
  for (++i; i < n; ++i) {
    if (v[i] == max) {
      printf(" %d", i+1);
    }
  }
  printf("\n");
}