# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27258 | TAMREF | Star triangles (IZhO11_triangle) | C++11 | 269 ms | 9052 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |