#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin >> n;
ll x[n];
ll y[n];
for(ll i = 0; i < n; i++){
cin >> x[i] >> y[i];
}
unordered_map <ll, ll> freqX;
unordered_map <ll, ll> freqY;
ll ans = 0;
for(ll i : x){
freqX[i] = 0;
}
for(ll i : y){
freqY[i] = 0;
}
for(ll i : x){
freqX[i]++;
}
for(ll i : y){
freqY[i]++;
}
for(ll i = 0; i < n; i++){
ans += (freqX[x[i]] - 1)*(freqY[y[i]] - 1);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
10 ms |
952 KB |
Output is correct |
13 |
Correct |
10 ms |
956 KB |
Output is correct |
14 |
Correct |
12 ms |
1304 KB |
Output is correct |
15 |
Correct |
102 ms |
6588 KB |
Output is correct |
16 |
Correct |
114 ms |
6924 KB |
Output is correct |
17 |
Correct |
100 ms |
6536 KB |
Output is correct |
18 |
Correct |
125 ms |
6580 KB |
Output is correct |
19 |
Correct |
274 ms |
13328 KB |
Output is correct |
20 |
Correct |
226 ms |
10396 KB |
Output is correct |
21 |
Correct |
352 ms |
14164 KB |
Output is correct |
22 |
Correct |
388 ms |
14156 KB |
Output is correct |