Submission #17470

#TimeUsernameProblemLanguageResultExecution timeMemory
17470NamnamseoStar triangles (IZhO11_triangle)C++98
100 / 100
251 ms8116 KiB
#include <cstdio> #include <algorithm> using namespace std; int cx[300010]; int cy[300010]; int px[300010]; int pxn; int py[300010]; int pyn; int n; int x[300010]; int y[300010]; int main() { scanf("%d",&n); int i; for(i=0;i<n;++i){ scanf("%d%d",x+i,y+i); px[i]=x[i]; py[i]=y[i]; } sort(px,px+n); sort(py,py+n); pxn=unique(px,px+n)-px; pyn=unique(py,py+n)-py; for(i=0;i<n;++i){ x[i]=lower_bound(px,px+pxn,x[i])-px; y[i]=lower_bound(py,py+pyn,y[i])-py; ++cx[x[i]]; ++cy[y[i]]; } long long ans=0; for(i=0;i<n;++i){ ans += (cx[x[i]]-1)*1ll*(cy[y[i]]-1); } printf("%lld\n",ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...