Submission #27193

#TimeUsernameProblemLanguageResultExecution timeMemory
27193TAMREF2circles (balkan11_2circles)C++11
10 / 100
0 ms3784 KiB
#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)

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