# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379588 | penguinhacker | Star triangles (IZhO11_triangle) | C++14 | 208 ms | 10712 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |