Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8. Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
  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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include <stdio.h>
#include <math.h>
#define N 200000
#include <vector>
#include <stack>

using namespace std;
//int deg[]
//state[] - 0 - ok, 1 - in queue, 2 - deleted
/*
1. init deg, state
2. while (queue/sth not empty) {
        get first
        sprawdz sasiadow: czy ktorys ma stan = 0 && deg == d (tzn. czy mu teraz spadnie ponizej d)
    }
3. znalezc najwieksza spojna skladowa
 */
vector<int> adj[N+1];
int deg[N+1];
int state[N+1];
vector<int> vertices_to_delete;
int connected_cout = 0;

int vertex_component_id[N+1];
int visited[N+1];
int component_size[N+1];


void print_list_to_delete(int n) {
    printf("Lista wierzcholkow do usuniecia\n");
    for(vector<int>::iterator it = vertices_to_delete.begin(); it != vertices_to_delete.end(); ++it) {
        /* std::cout << *it; ... */
        printf("%d\n", *it);
    }
}

int main() {
    int n, m, d;
    scanf("%d %d %d", &n, &m, &d);

    for (int i = 0; i < m; ++i) {
        int v, u;
        scanf("%d %d", &v, &u);
        adj[v].push_back(u);
        adj[u].push_back(v);
    }

    for (int i = 1; i <= n; ++i) {
        visited[i] = 0;
        vertex_component_id[i] = -1;
        deg[i] = adj[i].size();
        if (deg[i] < d) {
            //printf("usun� wierzcholek %d\n",i);
            vertices_to_delete.push_back(i);
            state[i] = 1;
        } else {
            state[i] = 0;
        }

    }

    for (int i = 1; i <= n; ++i) {
        //printf("wierzcholek %d ma stopien = %d\n", i, deg[i]);
    }

    //print_list_to_delete(n);

    while (!vertices_to_delete.empty()) {
        int v = vertices_to_delete.back();
        //printf("usuwam wierzcholek %d\n",v);
        vertices_to_delete.pop_back();

        state[v] = 2;

        for(vector<int>::iterator it = adj[v].begin(); it != adj[v].end(); ++it) {
            int u = *it;
            deg[u]--;

            if (state[u] == 0 && deg[u] < d) {
                //printf("usun� wierzcholek %d\n",u);
                vertices_to_delete.push_back(u);
                state[u] = 1;
            }

        }
    }

    stack<int> vertexes_to_visit;

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


        if (state[i] == 0 && visited[i] == 0) {
            //printf("dodaje wierzcholek %d\n",i);

            vertexes_to_visit.push(i);

            connected_cout++;
            component_size[connected_cout] = 0;

            while (!vertexes_to_visit.empty()) {
                int v = vertexes_to_visit.top();
                vertexes_to_visit.pop();

                //printf("odwiedzam wierzcholek %d\n",v);


                visited[v] = 2;
                vertex_component_id[v] = connected_cout;
                component_size[connected_cout]++;

                for(vector<int>::iterator it = adj[v].begin(); it != adj[v].end(); ++it) {
                    int u = *it;
                    if (state[u] == 0 && visited[u] == 0) {
                        visited[u] = 1;
                        vertexes_to_visit.push(u);
                        //printf("dodaje wierzcholek %d\n",u);

                    }
                }
            }
        }
    }

    int max_component_id;
    int max_component_size = -1;
    for (int i = 1; i <= connected_cout ; ++i) {
        //printf("skladowa %d ma rozmiar %d\n", i, component_size[i]);
        //printf("%d < %d ?\n", max_component_size, component_size[i]);
        if (max_component_size < component_size[i]) {
            max_component_id = i;
            max_component_size = component_size[i];
        }
    }


    for (int i = 1; i <=n ; ++i) {
        //printf("wierzcholek %d w skladowej %d\n", i, vertex_component_id[i]);
    }

    //printf("max skladowa ma rozmiar: %d (id = %d)\n", max_component_size, max_component_id);

    if (max_component_size == -1) {
        printf("NIE");
    } else {
        printf("%d\n", max_component_size);
        for (int i = 1; i <= n ; ++i) {
            if (vertex_component_id[i] == max_component_id) {
                printf("%d ", i);
            }
        }
    }

    return 0;
}