#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n;
cin>>n;
pair<int,int>kartesius[n+1];
map<int,int >y;
map<int,int>x;
map<pair<int,int>,int> cek;
for(int j=1;j<=n;j++ ){
cin>>kartesius[j].first>>kartesius[j].second;
int q=kartesius[j].first;
int w=kartesius[j].second;
if(cek[{q,w}]!=1){
cek[{q,w}]=1;
if(!x.count(q)){
x[q]=1;
}
else{
x[q]++;
}
if(!y.count(w)){
y[w]=1;
}
else{
y[w]++;
}
}
}
int ans=0;
for(int k=1;k<=n;k++){
int hori=kartesius[k].first;
int ver=kartesius[k].second;
if(cek[{hori,ver}]==1){
ans+=(x[hori]-1)*(y[ver]-1);
cek[{hori,ver}]=2;
}
}
// cout<<cek[{1,1}]<<endl;
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
14 ms |
1884 KB |
Output is correct |
13 |
Correct |
14 ms |
1908 KB |
Output is correct |
14 |
Correct |
20 ms |
2372 KB |
Output is correct |
15 |
Correct |
235 ms |
14448 KB |
Output is correct |
16 |
Correct |
245 ms |
15184 KB |
Output is correct |
17 |
Correct |
224 ms |
14292 KB |
Output is correct |
18 |
Correct |
220 ms |
14068 KB |
Output is correct |
19 |
Correct |
759 ms |
32344 KB |
Output is correct |
20 |
Correct |
508 ms |
24404 KB |
Output is correct |
21 |
Correct |
922 ms |
34432 KB |
Output is correct |
22 |
Correct |
851 ms |
34436 KB |
Output is correct |