#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<pair<int,int>>v(n);
for(int i=0; i<n; i++){
int j,k;
cin>>j>>k;
pair<int,int>p={j,k};
v[i]=p;
}
long long ans=0;
sort(v.begin(),v.end());
for(int i=0; i<v.size(); i++){
int h=0;
for(int j=i+1; j<v.size(); j++){
if(h==1 && v[j].first!=v[i].first)break;
if(v[j].first==v[i].first){
h=1;
for(int t=0; t<v.size(); t++){
if(t!=i && t!=j){
if(v[t].second==v[i].second ){
ans++;
}
if(v[t].second==v[j].second)ans++;
}
}
}
}
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |