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

using namespace std;

int main()
{
    int m,n,d;
    cin >> m >> n >> d;
    int left;
    int right;

    int * countM=new int [m];
    bool * mS=new bool [m];
    int S=0;
    for(int i=0;i<m;i++)
    {
        mS[i]=false;
        countM[i]=0;
    }

    for(int i=0;i<n;i++)
    {
        cin >> left >> right;


        countM[ left-1]++;
        if(countM[ left-1]>=d)
        {
            if (mS[ left-1]==false)
            {
                mS[ left-1]=true;
                S++;
            }
        }
        countM[right-1]++;
        if(countM[ right-1]>=d)
        {
            if (mS[ right-1]==false)
            {
                mS[ right-1]=true;
                S++;
            }
        }
    }


    if(S>2)
    {
        cout << S << endl;

        for(int i=0;i<m;i++)
        {
            if(mS[i]) cout << i+1 << " ";
        }
        cout << endl;
    }
    else cout << "NIE" << endl;

    return 0;
}