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
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

const int MAX_N = 2e5 + 9;

typedef pair<int, int> PII;

bitset<MAX_N> deleted;

vector<int> G[MAX_N];
int in[MAX_N];
int component[MAX_N];
vector<int> components[MAX_N];

int currentComponent = 1;
int n, m, k;

void Annihilate(int v)
{
    deleted[v] = true;

    for(int i = 0; i < G[v].size(); ++i)
    {
        int u = G[v][i];

        --in[u];

        if(!deleted[u] && in[u] < k)
            Annihilate(u);
    }

    return;
}

void DFS(int v)
{
    component[v] = currentComponent;
    components[currentComponent].pb(v);

    for(int i = 0; i < G[v].size(); ++i)
    {
        int u = G[v][i];

        if(!deleted[u] && component[u] == 0)
            DFS(u);
    }

    return;
}

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

    int a, b;

    for(int i = 0; i < m; ++i)
    {
        scanf("%d%d", &a, &b);
        ++in[a];
        ++in[b];

        G[a].pb(b);
        G[b].pb(a);
    }

    for(int i = 1; i <= n; ++i)
        if(!deleted[i] && in[i] < k)
            Annihilate(i);

    int maxx = 0;
    int maxxComponent = 0;

    for(int i = 1; i <= n; ++i)
    {
        if(!deleted[i] && component[i] == 0)
        {
            DFS(i);

            if(components[currentComponent].size() > maxx)
            {
                maxx = components[currentComponent].size();
                maxxComponent = currentComponent;
            }

            ++currentComponent;
        }
    }

    if(maxx == 0)
    {
        printf("NIE");
        return 0;
    }

    sort(components[maxxComponent].begin(), components[maxxComponent].end());

    printf("%d\n", maxx);

    for(int i = 0; i < maxx; ++i)
        printf("%d ", components[maxxComponent][i]);

    return 0;
}