# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27193 | TAMREF | 2circles (balkan11_2circles) | C++11 | 0 ms | 3784 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 double lf;
struct pt{
lf x,y;
pt(int _x=0,int _y=0):x((double)_x),y((double)_y){}
pt operator- (pt z){return pt(x-z.x,y-z.y);}
};
inline lf d(pt u, pt v){
return ((u.x-v.x)*(u.x-v.x)+(u.y-v.y)*(u.y-v.y));
}
inline lf angle(pt u, pt v, pt w){
lf a=d(u,v),b=d(v,w),c=d(u,w);
return acos((a+b-c)/(2*sqrt(a*b)));
}
pt t[100005];
int N;
bool valid3(lf r){
for(int x=0;x<3;x++){
lf the1 = angle(t[(x+2)%3],t[x],t[(x+1)%3]),
the2 = angle(t[x],t[(x+1)%3],t[(x+2)%3]),
d12 = sqrt(d(t[x],t[(x+1)%3]));
if(d12-(r/tan(the2/2))-(r/tan(the1/2))>2*r) return true;
}
return false;
}
int main(){
scanf("%d",&N);
if(N>3) return !printf("0.000\n");
for(int i=0,x,y;i<N;i++){
scanf("%d%d",&x,&y);
t[i]=pt(x,y);
}
lf l=1e-7,h=1e7,m;
while(h-l>=1e-3){
m=(l+h)/2.0;
if(valid3(m)) l=m;
else h=m;
}
printf("%.3f\n",m);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |