Submission #379588

#TimeUsernameProblemLanguageResultExecution timeMemory
379588penguinhackerStar triangles (IZhO11_triangle)C++14
100 / 100
208 ms10712 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int n, x[300000], y[300000], cx[300000], cy[300000]; void compress(int a[]) { vector<int> d(a, a + n); sort(d.begin(), d.end()); d.resize(unique(d.begin(), d.end()) - d.begin()); for (int i = 0; i < n; ++i) a[i] = lower_bound(d.begin(), d.end(), a[i]) - d.begin(); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> x[i] >> y[i]; compress(x); compress(y); for (int i = 0; i < n; ++i) ++cx[x[i]], ++cy[y[i]]; ll ans = 0; for (int i = 0; i < n; ++i) ans += (ll)(cx[x[i]] - 1) * (cy[y[i]] - 1); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...