Submission #987153

#TimeUsernameProblemLanguageResultExecution timeMemory
987153ezzzayStar triangles (IZhO11_triangle)C++14
100 / 100
744 ms34324 KiB
#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 timeMemoryGrader output
Fetching results...