#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n;
int x[N], y[N];
int cx[N], cy[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
}
vector<int> vx;
copy(x + 1, x + n + 1, back_inserter(vx));
sort(vx.begin(), vx.end());
vx.erase(unique(vx.begin(), vx.end()), vx.end());
vector<int> vy;
copy(y + 1, y + n + 1, back_inserter(vy));
sort(vy.begin(), vy.end());
vy.erase(unique(vy.begin(), vy.end()), vy.end());
for (int i = 1; i <= n; i++) {
cx[lower_bound(vx.begin(), vx.end(), x[i]) - vx.begin()]++;
cy[lower_bound(vy.begin(), vy.end(), y[i]) - vy.begin()]++;
}
long long ans = 0;
for (int i = 1; i <= n; i++) {
ans += (cx[lower_bound(vx.begin(), vx.end(), x[i]) - vx.begin()] - 1) * (cy[lower_bound(vy.begin(), vy.end(), y[i]) - vy.begin()] - 1);
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4440 KB |
Output is correct |
4 |
Correct |
2 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4560 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
4700 KB |
Output is correct |
13 |
Correct |
5 ms |
4700 KB |
Output is correct |
14 |
Correct |
7 ms |
4776 KB |
Output is correct |
15 |
Correct |
66 ms |
7756 KB |
Output is correct |
16 |
Correct |
70 ms |
8024 KB |
Output is correct |
17 |
Correct |
65 ms |
7756 KB |
Output is correct |
18 |
Correct |
71 ms |
7644 KB |
Output is correct |
19 |
Correct |
192 ms |
13384 KB |
Output is correct |
20 |
Correct |
134 ms |
10724 KB |
Output is correct |
21 |
Correct |
220 ms |
13900 KB |
Output is correct |
22 |
Correct |
210 ms |
14400 KB |
Output is correct |