Advertisement
a53

GradeK

a53
Feb 25th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ifstream fin("gradek.in");
  6. ofstream fout("gradek.out");
  7.  
  8. int n , a[105][105], g[105], k;
  9.  
  10. int main()
  11. {
  12. int i , j;
  13. fin >> n >> k;
  14. while(fin >> i >> j)
  15. {
  16. a[i][j] = a[j][i] = 1;
  17. }
  18.  
  19. for(int i = 1; i <= n; i++)
  20. {
  21. g[i] = 0;
  22. for(int j = 1; j <= n; ++j)
  23. if(a[i][j] == 1)
  24. g[i] ++;
  25. }
  26. int cnt = 0;
  27. for(int i = 1; i <= n; i++)
  28. if(g[i] == g[k])
  29. cnt ++;
  30. fout << cnt << '\n';
  31. for(int i = 1; i <= n; i++)
  32. if(g[i] == g[k])
  33. fout << i << " ";
  34. fout << '\n';
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement