#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 3e5 + 10;
int x[N], y[N], dx[N], dy[N];
map<int, int> mx, my;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
for(int i=0; i<n; i++){
cin >> x[i] >> y[i];
mx[x[i]] = my[y[i]] = 0;
}
int cnt = 0;
for(auto X : mx)
mx[X.F] = cnt++;
cnt = 0;
for(auto Y : my)
my[Y.F] = cnt++;
for(int i=0; i<n; i++){
x[i] = mx[x[i]];
y[i] = my[y[i]];
dx[x[i]]++;
dy[y[i]]++;
}
ll ans = 0;
for(int i=0; i<n; i++)
ans += 1LL * (dx[x[i]] - 1) * (dy[y[i]] - 1);
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6872 KB |
Output is correct |
2 |
Correct |
0 ms |
6872 KB |
Output is correct |
3 |
Correct |
0 ms |
6872 KB |
Output is correct |
4 |
Correct |
0 ms |
6872 KB |
Output is correct |
5 |
Correct |
0 ms |
6872 KB |
Output is correct |
6 |
Correct |
0 ms |
6872 KB |
Output is correct |
7 |
Correct |
0 ms |
6872 KB |
Output is correct |
8 |
Correct |
0 ms |
6872 KB |
Output is correct |
9 |
Correct |
0 ms |
6872 KB |
Output is correct |
10 |
Correct |
0 ms |
6872 KB |
Output is correct |
11 |
Correct |
0 ms |
6872 KB |
Output is correct |
12 |
Correct |
6 ms |
7268 KB |
Output is correct |
13 |
Correct |
6 ms |
7268 KB |
Output is correct |
14 |
Correct |
9 ms |
7664 KB |
Output is correct |
15 |
Correct |
229 ms |
9776 KB |
Output is correct |
16 |
Correct |
253 ms |
9776 KB |
Output is correct |
17 |
Correct |
259 ms |
9776 KB |
Output is correct |
18 |
Correct |
276 ms |
9776 KB |
Output is correct |
19 |
Correct |
663 ms |
9908 KB |
Output is correct |
20 |
Correct |
543 ms |
9908 KB |
Output is correct |
21 |
Correct |
623 ms |
9908 KB |
Output is correct |
22 |
Correct |
653 ms |
9908 KB |
Output is correct |