Na2a

ROI A

Jul 14th, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define pii pair<int, int>
  4.  
  5. #define pb push_back
  6. #define mp make_pair
  7.  
  8. #define f first
  9. #define s second
  10.  
  11. using namespace std;
  12.  
  13. typedef long long ll;
  14.  
  15. const int MAXN = (int) 3e5 + 7;
  16. const int INF = (int) 1e9 + 7;
  17.  
  18. int n;
  19. int cnt[101];
  20.  
  21. ll solve(vector<pii> a) {
  22.   ll res = 0;
  23.   ll sum = 0;
  24.   vector<int> all[101];
  25.   for (auto it : a)
  26.     all[it.f].pb(it.s);
  27.  
  28.   memset(cnt, 0, sizeof cnt);
  29.   for (int x = 1; x <= 100; x++) {
  30.     for (auto it : all[x]) {
  31.       res += sum - cnt[it];
  32.     }
  33.     for (auto it : all[x])
  34.       sum++, cnt[it]++;
  35.   }
  36.   return res;
  37. }
  38.  
  39. vector<pii> f1[101], f2[101], f3[101];
  40. ll ans;
  41.  
  42. int main() {
  43.   #ifdef LOCAL
  44.   freopen("in", "r", stdin);
  45.   #else
  46.   freopen("onlyone.in", "r", stdin);
  47.   freopen("onlyone.out", "w", stdout);
  48.   #endif
  49.  
  50.   scanf("%d", &n);
  51.   for (int i = 1; i <= n; i++) {
  52.     int x, y, z;
  53.     scanf("%d%d%d", &x, &y, &z);
  54.     f1[x].pb(mp(y, z));
  55.     f2[y].pb(mp(x, z));
  56.     f3[z].pb(mp(x, y));
  57.   }
  58.   for (int x = 1; x <= 100; x++) {
  59.     ans += solve(f1[x]);
  60.     ans += solve(f2[x]);
  61.     ans += solve(f3[x]);
  62.   }
  63.   cout << ans;
  64.   return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment