Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n,m;
  6. int graf[1001];//tu ilosc czerwonych krawedzi dla kazdego wierzcholka
  7.  
  8. int p,k;
  9.  
  10. long long rozne;
  11. long long all;
  12.  
  13. int main()
  14. {
  15. ios_base::sync_with_stdio(0);
  16.  
  17. cin>>n>>m;
  18.  
  19. all = n * (n-1) * (n-2) / 6;
  20.  
  21. for(int i = 1; i <= m; i++)
  22. {
  23. cin>>p>>k;
  24. graf[p]++;
  25. graf[k]++;
  26. }
  27.  
  28. for(int i = 1; i <= n; i++)
  29. {
  30. rozne += (graf[i] * (n - 1 - graf[i]) / 2 ); // czerwone * czarne / 2;
  31. }
  32.  
  33. cout<<all - rozne;
  34.  
  35.  
  36.  
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement