Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n,m,a[101][101],x[105];
  5. bool ok=true;
  6.  
  7. int main()
  8. {
  9. cin>>n>>m;
  10. for(int i=1; i<=m; i++)
  11. {
  12. int p,q;
  13. cin>>p>>q;
  14. a[p][q]=1;
  15. x[q]++;
  16.  
  17. }
  18. for(int i=1; i<=n; i++)
  19. if(x[i]==0) cout<<i<<" ",ok=false;
  20. if(ok==true)cout<<"NU EXISTA";
  21. return 0;
  22.  
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. #include <iostream>
  34. using namespace std;
  35.  
  36. int n,m,a[101][101],x[105];
  37. int main()
  38. {
  39. cin>>n>>m;
  40. for(int i=1; i<=m; i++)
  41. {
  42. int p,q;
  43. cin>>p>>q;
  44. a[p][q]=1;
  45. x[q]++;
  46.  
  47. }
  48. int maxim=-1;
  49. for(int i=1; i<=n;i++)
  50. if(x[i]>maxim) maxim=x[i];
  51. for(int i=1; i<=n; i++)
  52. if(x[i]==maxim) cout<<i<<" ";
  53. return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement