#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int N; cin >> N;
vector<pair<int, int>>v(N);
map<int, ll>cntX, cntY;
for(auto &[x, y]: v){
cin >> x >> y;
cntX[x]++;
cntY[y]++;
}
ll ans = 0;
for(auto &[x, y]: v){
ans += max(0LL, (cntX[x] - 1)*(cntY[y] - 1));
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Correct |
9 ms |
1116 KB |
Output is correct |
13 |
Correct |
9 ms |
1240 KB |
Output is correct |
14 |
Correct |
13 ms |
1628 KB |
Output is correct |
15 |
Correct |
128 ms |
7248 KB |
Output is correct |
16 |
Correct |
142 ms |
7504 KB |
Output is correct |
17 |
Correct |
156 ms |
7428 KB |
Output is correct |
18 |
Correct |
152 ms |
7252 KB |
Output is correct |
19 |
Correct |
355 ms |
12680 KB |
Output is correct |
20 |
Correct |
247 ms |
10180 KB |
Output is correct |
21 |
Correct |
384 ms |
13272 KB |
Output is correct |
22 |
Correct |
393 ms |
13820 KB |
Output is correct |