# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
446069 | simon2712 | Star triangles (IZhO11_triangle) | C++14 | 1 ms | 204 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;
ifstream fin("triangles.in");
ofstream fout("triangles.out");
pair<int,int> v[3000001],v2[3000001];
int main()
{
int n,i,st,dr,mij,st2,dr2,st3,dr3;
unsigned long long rez=0;
fin>>n;
for(i=1;i<=n;i++){
fin>>v[i].first>>v[i].second;
v2[i].first=v[i].second;
v2[i].second=v[i].first;
}
sort(v+1,v+n+1);
sort(v2+1,v2+n+1);
for(i=1;i<=n;i++)
{
st=1;
dr=n;
while(st<=dr)
{
mij=(st+dr)/2;
if(v[mij].first<v[i].first)
st=mij+1;
else
dr=mij-1;
}
st2=st;
st=1;
dr=n;
while(st<=dr)
{
mij=(st+dr)/2;
if(v[mij].first>v[i].first)
dr=mij-1;
else
st=mij+1;
}
dr2=dr;
st=1;
dr=n;
while(st<=dr)
{
mij=(st+dr)/2;
if(v2[mij].first<v[i].second)
st=mij+1;
else
dr=mij-1;
}
st3=st;
st=1;
dr=n;
while(st<=dr)
{
mij=(st+dr)/2;
if(v2[mij].first>v[i].second)
dr=mij-1;
else
st=mij+1;
}
dr3=dr;
rez+=(dr3-st3)*(dr2-st2);
}
fout<<rez;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |