#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
struct Point{
int x, y;
}p[200010];
int n, x[200010], y[200010], xsum[200010], ysum[200010];
ll ans;
int main(){
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d%d", x + i, y + i);
p[i] = {x[i], y[i]};
}
sort(x, x + n);
sort(y, y + n);
for(int i = 0; i < n; i++){
p[i] = {(int)(lower_bound(x, x + n, p[i].x) - x), (int)(lower_bound(y, y + n, p[i].y) - y)};
xsum[p[i].x]++;
ysum[p[i].y]++;
}
for(int i = 0; i < n; i++){
ans += (ll)(xsum[p[i].x] - 1) * (ll)(ysum[p[i].y] - 1);
}
printf("%lld", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5772 KB |
Output is correct |
2 |
Correct |
0 ms |
5772 KB |
Output is correct |
3 |
Correct |
0 ms |
5772 KB |
Output is correct |
4 |
Correct |
0 ms |
5772 KB |
Output is correct |
5 |
Correct |
0 ms |
5772 KB |
Output is correct |
6 |
Correct |
0 ms |
5772 KB |
Output is correct |
7 |
Correct |
0 ms |
5772 KB |
Output is correct |
8 |
Correct |
0 ms |
5772 KB |
Output is correct |
9 |
Correct |
0 ms |
5772 KB |
Output is correct |
10 |
Correct |
0 ms |
5772 KB |
Output is correct |
11 |
Correct |
0 ms |
5772 KB |
Output is correct |
12 |
Correct |
2 ms |
5772 KB |
Output is correct |
13 |
Correct |
3 ms |
5772 KB |
Output is correct |
14 |
Correct |
0 ms |
5772 KB |
Output is correct |
15 |
Correct |
91 ms |
5772 KB |
Output is correct |
16 |
Correct |
104 ms |
5772 KB |
Output is correct |
17 |
Correct |
77 ms |
5772 KB |
Output is correct |
18 |
Correct |
77 ms |
5772 KB |
Output is correct |
19 |
Execution timed out |
2000 ms |
5768 KB |
Program timed out |
20 |
Correct |
171 ms |
5772 KB |
Output is correct |
21 |
Execution timed out |
2000 ms |
5768 KB |
Program timed out |
22 |
Execution timed out |
2000 ms |
5768 KB |
Program timed out |