#include <bits/stdc++.h>
using namespace std;
const int N=300000;
map<int,int> x,y;
int a[N],b[N];
int main() {
ios_base::sync_with_stdio(false);
long long ans=0;
int n;
cin>>n;
for (int i=0;i<n;i++){
cin>>a[i]>>b[i];
x[a[i]]++;
y[b[i]]++;
}
for (int i=0;i<n;i++){
ans+=(long long)(x[a[i]]-1)*(long long)(y[b[i]]-1);
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
452 KB |
Output is correct |
4 |
Correct |
1 ms |
560 KB |
Output is correct |
5 |
Correct |
1 ms |
580 KB |
Output is correct |
6 |
Correct |
1 ms |
584 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
680 KB |
Output is correct |
12 |
Correct |
11 ms |
1340 KB |
Output is correct |
13 |
Correct |
8 ms |
1616 KB |
Output is correct |
14 |
Correct |
13 ms |
2100 KB |
Output is correct |
15 |
Correct |
143 ms |
7180 KB |
Output is correct |
16 |
Correct |
156 ms |
9720 KB |
Output is correct |
17 |
Correct |
136 ms |
11788 KB |
Output is correct |
18 |
Correct |
176 ms |
13900 KB |
Output is correct |
19 |
Correct |
378 ms |
21480 KB |
Output is correct |
20 |
Correct |
277 ms |
25124 KB |
Output is correct |
21 |
Correct |
405 ms |
32292 KB |
Output is correct |
22 |
Correct |
419 ms |
38988 KB |
Output is correct |