Submission #27258

#TimeUsernameProblemLanguageResultExecution timeMemory
27258TAMREFStar triangles (IZhO11_triangle)C++11
100 / 100
269 ms9052 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx=3e5+5; int x[mx], y[mx], xc[mx], yc[mx], xo[mx], yo[mx]; int main(){ int N; scanf("%d",&N); for(int i=0;i<N;i++){ scanf("%d%d",&x[i],&y[i]); xc[i]=x[i], yc[i]=y[i]; } int u,v; sort(xc,xc+N); u=unique(xc,xc+N)-xc; sort(yc,yc+N); v=unique(yc,yc+N)-yc; for(int i=0;i<N;i++){ x[i]=lower_bound(xc,xc+u,x[i])-xc; ++xo[x[i]]; y[i]=lower_bound(yc,yc+v,y[i])-yc; ++yo[y[i]]; } ll ans=0; for(int i=0;i<N;i++){ ans+=1LL*(xo[x[i]]-1)*(yo[y[i]]-1); } printf("%lld\n",ans); }

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:8:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
                   ^
triangle.cpp:10:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x[i],&y[i]);
                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...