Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct vhash { int operator()(const vector<int> &V) const { int hash = 0; for(int i = 0; i < V.size(); ++i) { hash += V[i]; } return hash; } };
  5. unordered_map < vector <int>, int, vhash > g;
  6.  
  7. int main() {
  8. freopen("cowpatibility.in", "r", stdin);
  9. freopen("cowpatibility.out", "w", stdout);
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(0);
  12. int n;
  13. cin >> n;
  14. vector < vector <int> > a(n);
  15. for(int i = 0; i < n; ++i) {
  16. for(int j = 0; j < 5; ++j) {
  17. int x;
  18. cin >> x;
  19. a[i].push_back(x);
  20. }
  21. sort(a[i].begin(), a[i].end());
  22. }
  23. long long ans = 0;
  24. for(int i = 0; i < n; ++i) {
  25. for(int j = 1; j < (1 << 5); ++j) {
  26. vector <int> p;
  27. int cnt = 0;
  28. for(int x = 0; x < 5; ++x) {
  29. if((j >> x) & 1) {
  30. ++cnt;
  31. p.push_back(a[i][x]);
  32. }
  33. }
  34. if(cnt % 2) ans += g[p];
  35. else ans -= g[p];
  36. }
  37. for(int j = 1; j < (1 << 5); ++j) {
  38. vector <int> p;
  39. for(int x = 0; x < 5; ++x) {
  40. if((j >> x) & 1) {
  41. p.push_back(a[i][x]);
  42. }
  43. }
  44. g[p]++;
  45. }
  46. }
  47. cout << 1LL * n * (n - 1) / 2 - ans << '\n';
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement