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

using namespace std;

int main() {

int m, n, p=0, d, a, b;
static int T[200002];
static int S[200002];
static int K[200002];

cin >> n >> m >> d;
for (int i=0; i<m; i++){
    cin >> a >> b;
    T[i]=a;
    S[i]=b;
    }

while(p!=m){
p=0;
      for(int i=1; i<=m; i++){
          if(K[i]!=200001){K[i]=0;}}
   
      for(int i=0; i<m; i++){
          if(T[i]!=0){K[T[i]]=K[T[i]]+1;}
          if(S[i]!=0){K[S[i]]=K[S[i]]+1;}
          }
       
       
      for(int i=1; i<=m; i++){
          if(K[i]<d){T[i-1]=0;
                     S[i-1]=0;
                     K[i]=200001;}
          else{p=p+1;}
          }  
      }
      
int w=0;    
for (int i=1; i<=m; i++){
if(K[i]!=200001){w=w+1;}}
if(w==0){cout << "NIE" << '\n';}
else{
cout << w << '\n';
for (int i=1; i<=m; i++){
if(T[i-1]!=0){
cout << T[i-1] << ' ';}}}

    

    return 0;
}