#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=4e5+5;
vector<int>v[N];
signed main(){
int n;
cin>>n;
map<int,int>mpx,mpy,idx,idy;
vector<pair<int,int>>vc;
for(int i=1;i<=n;i++){
int x,y;
cin>>x>>y;
vc.pb({x,y});
idx[x];
idy[y];
}
int e=1,d=1;
for(auto it=idx.begin();it!=idx.end();it++){
it->ss =e++;
}
for(auto it=idy.begin();it!=idy.end();it++){
it->ss =d++;
}
for(auto p:vc){
int x= idx[p.ff];
int y=idy[p.ss];
mpx[x]++;
mpy[y]++;
v[x].pb(y);
}
int cnt=0;
for(auto it=mpx.begin();it!=mpx.end();it++){
int x= it->ff;
for(auto y:v[x]){
cnt+= (mpy[y]-1)*(mpx[x]-1);
}
}
cout<<cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9816 KB |
Output is correct |
2 |
Correct |
5 ms |
9820 KB |
Output is correct |
3 |
Correct |
6 ms |
9820 KB |
Output is correct |
4 |
Correct |
6 ms |
9820 KB |
Output is correct |
5 |
Correct |
6 ms |
9816 KB |
Output is correct |
6 |
Correct |
6 ms |
9596 KB |
Output is correct |
7 |
Correct |
6 ms |
9820 KB |
Output is correct |
8 |
Correct |
6 ms |
9820 KB |
Output is correct |
9 |
Correct |
7 ms |
9820 KB |
Output is correct |
10 |
Correct |
6 ms |
9820 KB |
Output is correct |
11 |
Correct |
6 ms |
9840 KB |
Output is correct |
12 |
Correct |
17 ms |
11480 KB |
Output is correct |
13 |
Correct |
22 ms |
11472 KB |
Output is correct |
14 |
Correct |
27 ms |
12528 KB |
Output is correct |
15 |
Correct |
216 ms |
22972 KB |
Output is correct |
16 |
Correct |
253 ms |
23488 KB |
Output is correct |
17 |
Correct |
219 ms |
22976 KB |
Output is correct |
18 |
Correct |
227 ms |
22976 KB |
Output is correct |
19 |
Correct |
636 ms |
32988 KB |
Output is correct |
20 |
Correct |
465 ms |
28772 KB |
Output is correct |
21 |
Correct |
693 ms |
34068 KB |
Output is correct |
22 |
Correct |
744 ms |
34324 KB |
Output is correct |