Submission #1050975


Source Code Expand

#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;
struct point{
    double x, y, z;
    point(){}
    point(double x_,double y_, double z_ = 1.0){
        x=x_,y=y_,z=z_;
    }
    point Cross(const point &p){
        return point(y*p.z-z*p.y,z*p.x-x*p.z,x*p.y-y*p.x);
    }
    point operator +(const point &p)const{
        return point(x+p.x,y+p.y);
    }
    point operator -(const point &p)const{
        return point(x-p.x,y-p.y);
    }
    point To2D(){
        return point(x/z,y/z);
    }
    point operator *(const double &k)const{
        return point(k*x,k*y);
    }
    point Rot(){
        return point(-y,x);
    }
    double SZ(){
        return sqrt(x*x+y*y);
    }
};
double ccw(point a, point b, point c){
    return (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);
}
double Area(point a, point b, point c){
    double t = a.x*b.y-a.y*b.x+b.x*c.y-b.y*c.x+c.x*a.y-c.y*a.x;
    if(t<0)t=-t;
    return t*0.5;
}
void Input(point &p){
    scanf("%lf%lf",&p.x,&p.y);
}
point Seg(point a, point b){
    return point(b.y-a.y,a.x-b.x,a.y*b.x-a.x*b.y);
}
point Move(point a, point b, double d){
    point tp = (b-a).Rot();
    tp = tp * (1.0/ tp.SZ()) * d;
    return Seg(a+tp,b+tp);
}
point Inter(point a, point b){
    point tp = (a.Cross(b)).To2D();
    return tp;
}
bool Pos(double r, point A, point B, point C){
    point t1 = Move(A,B,r), t2 = Move(B,C,r), t3 = Move(C,A,r);
    point P1 = Inter(t1,t2),P2 = Inter(t2,t3),P3=Inter(t3,t1);
    if((P1-P2).SZ()>=r*2)return true;
    if((P2-P3).SZ()>=r*2)return true;
    if((P1-P3).SZ()>=r*2)return true;
    return false;
}
int main(){
    point P1, P2, P3;
    Input(P1);
    Input(P2);
    Input(P3);
    if(ccw(P1,P2,P3)<0)swap(P2,P3);
    double ee = Area(P1,P2,P3) / ((P1-P2).SZ() + (P1-P3).SZ() + (P2-P3).SZ()) * 2, bb = 0.0, mid;
    for(int TT=0;TT<50;TT++){
        mid = (bb+ee)*0.5;
        if(!Pos(mid,P1,P2,P3))ee=mid;
        else bb = mid;
    }
    printf("%.11f\n",(bb+ee)*0.5);
}

Submission Info

Submission Time
Task B - Inscribed Bicycle
User ainta
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2056 Byte
Status AC
Exec Time 2 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘void Input(point&)’:
./Main.cpp:42:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lf%lf",&p.x,&p.y);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 18
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 2 ms 128 KB
001.txt AC 2 ms 128 KB
002.txt AC 2 ms 128 KB
003.txt AC 2 ms 128 KB
004.txt AC 2 ms 128 KB
005.txt AC 2 ms 128 KB
006.txt AC 2 ms 128 KB
007.txt AC 2 ms 128 KB
008.txt AC 2 ms 128 KB
009.txt AC 2 ms 128 KB
010.txt AC 2 ms 128 KB
011.txt AC 2 ms 128 KB
012.txt AC 2 ms 128 KB
013.txt AC 2 ms 128 KB
014.txt AC 2 ms 128 KB
015.txt AC 2 ms 128 KB
example0.txt AC 2 ms 128 KB
example1.txt AC 2 ms 128 KB