#include <iostream>
using namespace std;
int main()
{
int n; int m; int d; int ilosc=0;
cin >> n;
cin >> m;
cin >> d;
int miasta[n+1];
int dobre[n];
for(int counter=1; counter<n+1; counter++)
miasta[counter]=0;
for(int counter=1; counter<n; counter++)
dobre[counter]=0;
int a[m]; int b[m];
for(int counter=0; counter<m; counter++)
{
cin >> a[counter];
cin >> b[counter];
miasta[a[counter]]=miasta[a[counter]]+1;
miasta[b[counter]]=miasta[b[counter]]+1;
}
for(int counter=1; counter<n+1; counter++)
{
if(miasta[counter]>=d)
{
dobre[ilosc]=counter;
ilosc++;
}
}
if(dobre[1]==0)
{
cout << "NIE";
return 0;
}
cout << ilosc << endl;
for(int counter=0; counter<ilosc-1; counter++)
cout << dobre[counter] << " ";
cout << dobre[ilosc-1];
return 0;
}
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 | #include <iostream> using namespace std; int main() { int n; int m; int d; int ilosc=0; cin >> n; cin >> m; cin >> d; int miasta[n+1]; int dobre[n]; for(int counter=1; counter<n+1; counter++) miasta[counter]=0; for(int counter=1; counter<n; counter++) dobre[counter]=0; int a[m]; int b[m]; for(int counter=0; counter<m; counter++) { cin >> a[counter]; cin >> b[counter]; miasta[a[counter]]=miasta[a[counter]]+1; miasta[b[counter]]=miasta[b[counter]]+1; } for(int counter=1; counter<n+1; counter++) { if(miasta[counter]>=d) { dobre[ilosc]=counter; ilosc++; } } if(dobre[1]==0) { cout << "NIE"; return 0; } cout << ilosc << endl; for(int counter=0; counter<ilosc-1; counter++) cout << dobre[counter] << " "; cout << dobre[ilosc-1]; return 0; } |
English