Problem:


Score : 500 points

Problem Statement

   #nck {
      width: 30px;
      height: auto;
   }

Snuke received a triangle as a birthday present.
The coordinates of the three vertices were (x_1, y_1), (x_2, y_2), and (x_3, y_3).

He wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch).
Compute the maximum possible radius of the circles.

Constraints

0 ≤ x_i, y_i ≤ 1000

The coordinates are integers.

The three points are not on the same line.

Input

The input is given from Standard Input in the following format:

x_1 y_1
x_2 y_2
x_3 y_3

Output

Print the maximum possible radius of the circles.
The absolute error or the relative error must be at most 10^{-9}.

Sample Input 1

0 0
1 1
2 0

Sample Output 1

0.292893218813

Sample Input 2

3 1
1 5
4 9

Sample Output 2

0.889055514217



Sample input:
0 0
1 1
2 0


Sample output:
0.292893218813

Submission status: Wrong Answer

Solution code:
import math

def btabs(lis):

    return (lis[0] ** 2 + lis[1] ** 2) ** 0.5

def inner_product(la,lb):

    return la[0] * lb[0] + la[1] * lb[1]



ans = 0

x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())

A = [x1-x2,y1-y2]
B = [x1-x3,y1-y3]
C = [x2-x3,y2-y3]

brlis = []
brlis.append([btabs(A),A])
brlis.append([btabs(B),B])
brlis.append([btabs(C),C])

brlis.sort()
brlis.reverse()

A = brlis[0][1]
B = brlis[1][1]
C = brlis[2][1]

recAB = abs(math.acos(inner_product(A,B) / (btabs(A)*btabs(B))))
recAC = abs(math.acos(inner_product(A,C) / (btabs(A)*btabs(C))))

recAB /= 2
recAC /= 2

ans = max(ans, btabs(A) / ( (1/math.tan(recAB)) + 2 + (1/math.tan(recAC)) ) )



A = brlis[1][1]
B = brlis[0][1]
C = brlis[2][1]

recAB = abs(math.acos(inner_product(A,B) / (btabs(A)*btabs(B))))
recAC = abs(math.acos(inner_product(A,C) / (btabs(A)*btabs(C))))

recAB /= 2
recAC /= 2

ans = max(ans, btabs(A) / ( (1/math.tan(recAB)) + 2 + (1/math.tan(recAC)) ) )


A = brlis[2][1]
B = brlis[1][1]
C = brlis[0][1]

recAB = abs(math.acos(inner_product(A,B) / (btabs(A)*btabs(B))))
recAC = abs(math.acos(inner_product(A,C) / (btabs(A)*btabs(C))))

recAB /= 2
recAC /= 2

ans = max(ans, btabs(A) / ( (1/math.tan(recAB)) + 2 + (1/math.tan(recAC)) ) )


print (ans)

Submission status: Wrong Answer

Solution code:
import math

def btabs(lis):

    return (lis[0] ** 2 + lis[1] ** 2) ** 0.5

def inner_product(la,lb):

    return la[0] * lb[0] + la[1] * lb[1]





x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())

A = [x1-x2,y1-y2]
B = [x1-x3,y1-y3]
C = [x2-x3,y2-y3]

brlis = []
brlis.append([btabs(A),A])
brlis.append([btabs(B),B])
brlis.append([btabs(C),C])

brlis.sort()
brlis.reverse()

A = brlis[0][1]
B = brlis[1][1]
C = brlis[2][1]

recAB = abs(math.acos(inner_product(A,B) / (btabs(A)*btabs(B))))
recAC = abs(math.acos(inner_product(A,C) / (btabs(A)*btabs(C))))

recAB /= 2
recAC /= 2

print ( btabs(A) / ( (1/math.tan(recAB)) + 2 + (1/math.tan(recAC)) ) )

Submission status: Wrong Answer

Solution code:
def euclid(a,b,c,d):
    return ( (a-c)**2 + (b-d)**2 )**0.5

def triangle_area(p1,p2,p3):
    dx1, dx2 = p3[0] - p1[0], p2[0] - p1[0]
    dy1, dy2 = p3[1] - p1[1], p2[1] - p1[1]
    return dy2*dx1 - dy1*dx2

x1, y1 = [ int(v) for v in input().split() ]
x2, y2 = [ int(v) for v in input().split() ]
x3, y3 = [ int(v) for v in input().split() ]

a = euclid(x1, y1, x2, y2)
b = euclid(x2, y2, x3, y3)
c = euclid(x3, y3, x1, y1)
l = a + b + c
s = triangle_area((x1,y1),(x2,y2),(x3,y3))

ar = s / ( l + (2*s / a) )
br = s / ( l + (2*s / b) )
cr = s / ( l + (2*s / c) )

print(max(ar,br,cr))

Submission status: Wrong Answer

Solution code:
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
s=abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a=((x1-x2)**2+(y1-y2)**2)**0.5
b=((x2-x3)**2+(y2-y3)**2)**0.5
c=((x3-x1)**2+(y3-y1)**2)**0.5
mx1,my1=(x1+x2)/2,(y1+y2)/2
mx2,my2=(x2+x3)/2,(y2+y3)/2
mx3,my3=(x3+x1)/2,(y3+y1)/2
h1=((x3-mx1)**2+(y3-my1)**2)**0.5
h2=((x1-mx2)**2+(y1-my2)**2)**0.5
h3=((x2-mx3)**2+(y2-my3)**2)**0.5
m1=(c+h1)/(c+b+2*h1)
r1=(m1*s)/(c+h1+m1*a)
m2=(a+h2)/(a+c+2*h2)
r2=(m2*s)/(a+h2+m2*b)
m3=(b+h3)/(b+a+2*h3)
r3=(m3*s)/(b+h3+m3*c)
print(max(r1,r2,r3))

Submission status: Wrong Answer

Solution code:
import math
xy = []
for i in range(3):
    xy.append([int(item) for item in input().split()])
xy.append(xy[0])

dist = []
for i in range(3):
    distance = math.sqrt((xy[i][0] - xy[i+1][0])**2.0 + (xy[i][1] - xy[i+1][1])**2.0)
    dist.append([distance, i, (i+1) % 3, (i+2) % 3])
dist.sort(reverse=True)

def get_vector(a, b):
    v = [a[0] - b[0], a[1] - b[1]]
    return v

def norm(a):
    n = math.sqrt(a[0] * a[0] + a[1] * a[1])
    return n

a = get_vector(xy[dist[0][-1]], xy[dist[0][-2]])
b = get_vector(xy[dist[0][-3]], xy[dist[0][-2]])
c = get_vector(xy[dist[0][-1]], xy[dist[0][-3]])
d = get_vector(xy[dist[0][-2]], xy[dist[0][-3]])
bc = dist[0][0]

ctheta = (a[0] * b[0] + a[1] * b[1]) / (norm(a) * norm(b))
cphi = (c[0] * d[0] + c[1] * d[1]) / (norm(c) * norm(d))
htheta = (math.pi - math.acos(ctheta)) / 2.0
hphi = (math.pi - math.acos(ctheta)) / 2.0
r = bc / (math.tan(htheta) + math.tan(hphi) + 2)
print(r)

Submission status: Wrong Answer

Solution code:
ai = lambda: list(map(int, input().split()))

import numpy as np
import math


def calc(A,B,C):
    a = np.linalg.norm(B - C)
    b = np.linalg.norm(C - A)
    c = np.linalg.norm(A - B)
    cosC = np.inner(A-C, B-C)/(b*a)
    if cosC <= 0:
        return 0
    tanC = math.sqrt(1/(cosC**2)-1)
    return (1 - 1/cosC + tanC) * (a+b-c)/4


a = np.array(ai())
b = np.array(ai())
c = np.array(ai())
print(max(calc(a,b,c),calc(b,c,a),calc(c,a,b)))

Submission status: Time Limit Exceeded

Solution code:
def main():
    def b_search(a, b, value, delta):
        while True:
            med = (a+b)/2
            if abs(b-a) < delta:
                if value(b):
                    return b
                else:
                    return a
            elif value(med):
                a = med
            else:
                b = med

    x1, y1 = map(int, input().split())
    x2, y2 = map(int, input().split())
    x3, y3 = map(int, input().split())

    a = ((x1-x2)**2+(y1-y2)**2)**0.5
    b = ((x2-x3)**2+(y2-y3)**2)**0.5
    c = ((x3-x1)**2+(y3-y1)**2)**0.5

    m = max(a, b, c)
    if a == m:
        l = a
    elif b == m:
        x1, x2, x3 = x2, x3, x1
        y1, y2, y3 = y2, y3, y1
        l = b
    else:
        x1, x2, x3 = x3, x1, x2
        y1, y2, y3 = y3, y1, y2
        l = c

    x2 -= x1
    x3 -= x1
    y2 -= y1
    y3 -= y1
    x1, y1 = 0, 0

    if x2 < 0:
        x2 = -x2
        x3 = -x3
    if y2 < 0:
        y2 = -y2
        y3 = -y3

    cos = x2/l
    sin = -(1-cos**2)**0.5

    x2, y2 = l, 0
    x3, y3 = abs(cos*x3-sin*y3), abs(sin*x3+cos*y3)

    a = l
    b = (x3**2+y3**2)**0.5
    c = ((x2-x3)**2+(y2-y3)**2)**0.5

    def value(x):
        t1 = x*y3/x3
        t2 = (x2-x)*y3/(x2-x3)
        s1 = t1*x/2
        s2 = t2*(a-x)/2
        r1 = (2*s1)/(x+t1+(x**2+t1**2)**0.5)
        r2 = (2*s2)/((a-x)+t2+((a-x)**2+t2**2)**0.5)
        if r1 < r2:
            return True
        else:
            return False

    def value2(x):
        t1 = x*y3/x3
        s1 = t1*x/2
        r1 = (2*s1)/(x+t1+(x**2+t1**2)**0.5)
        return r1

    v = b_search(0, l, value, 10**(-15))
    print(value2(v))

main()

Submission status: Accepted

Solution code:
import math
x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())
ans = 0
for (xa,ya,xb,yb,xn,yn) in (x1,y1,x2,y2,x3,y3),(x2,y2,x3,y3,x1,y1),(x3,y3,x1,y1,x2,y2):
  xa -= xn
  ya -= yn
  xb -= xn
  yb -= yn
  xab = xa-xb
  yab = ya-yb
  L = math.hypot(xab,yab)
  cosa = (xab*xa+yab*ya)/(math.hypot(xa,ya)*math.hypot(xab,yab))
  cosb = (-xab*xb-yab*yb)/(math.hypot(xb,yb)*math.hypot(xab,yab))
  anga = math.acos(cosa)
  angb = math.acos(cosb)
  tana = math.tan(anga/2)
  tanb = math.tan(angb/2)
  ans = max(ans,L/(2+1/tana+1/tanb))
print(ans)

Submission status: Accepted

Solution code:
# cf16-exhibition-final-openB - Inscribed Bicycle
def main():
    x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())
    x2 -= x1
    y2 -= y1
    x3 -= x1
    y3 -= y1
    a = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    b = (x3 ** 2 + y3 ** 2) ** 0.5
    c = (x2 ** 2 + y2 ** 2) ** 0.5
    r = abs(x2 * y3 - x3 * y2) / (a + b + c)
    d = max(a, b, c)
    ans = r * d / (2 * r + d)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))


len1 = ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
len2 = ((p2[0] - p3[0]) ** 2 + (p2[1] - p3[1]) ** 2) ** 0.5
len3 = ((p3[0] - p1[0]) ** 2 + (p3[1] - p1[1]) ** 2) ** 0.5

l = (len1 + len2 + len3) / 2
s = (l * (l - len1) * (l - len2) * (l - len3)) ** 0.5
r = 2 * s /(len1 + len2 + len3)

def solve(mid):
    return (1 - mid / r) * max(len1, len2, len3) >= 2 * mid

ok = 0
ng = 10 ** 9
cnt = 0
while True:
    mid = (ok + ng) / 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
    cnt += 1
    if cnt > 60:
        break
print(ok)

Submission status: Accepted

Solution code:
def main():
    def b_search(a, b, value, delta):
        while True:
            med = (a+b)/2
            if abs(b-a) < delta:
                if value(b):
                    return b
                else:
                    return a
            elif value(med):
                a = med
            else:
                b = med

    x1, y1 = map(int, input().split())
    x2, y2 = map(int, input().split())
    x3, y3 = map(int, input().split())

    a = ((x1-x2)**2+(y1-y2)**2)**0.5
    b = ((x2-x3)**2+(y2-y3)**2)**0.5
    c = ((x3-x1)**2+(y3-y1)**2)**0.5

    m = max(a, b, c)
    if a == m:
        l = a
    elif b == m:
        x1, x2, x3 = x2, x3, x1
        y1, y2, y3 = y2, y3, y1
        l = b
    else:
        x1, x2, x3 = x3, x1, x2
        y1, y2, y3 = y3, y1, y2
        l = c

    x2 -= x1
    x3 -= x1
    y2 -= y1
    y3 -= y1
    x1, y1 = 0, 0

    if x2 < 0:
        x2 = -x2
        x3 = -x3
    if y2 < 0:
        y2 = -y2
        y3 = -y3

    cos = x2/l
    sin = -(1-cos**2)**0.5

    x2, y2 = l, 0
    x3, y3 = abs(cos*x3-sin*y3), abs(sin*x3+cos*y3)

    a = l
    b = (x3**2+y3**2)**0.5
    c = ((x2-x3)**2+(y2-y3)**2)**0.5

    def value(x):
        t1 = x*y3/x3
        t2 = (x2-x)*y3/(x2-x3)
        s1 = t1*x/2
        s2 = t2*(a-x)/2
        r1 = (2*s1)/(x+t1+(x**2+t1**2)**0.5)
        r2 = (2*s2)/((a-x)+t2+((a-x)**2+t2**2)**0.5)
        if r1 < r2:
            return True
        else:
            return False

    def value2(x):
        t1 = x*y3/x3
        s1 = t1*x/2
        r1 = (2*s1)/(x+t1+(x**2+t1**2)**0.5)
        return r1

    v = b_search(0, l, value, 10**(-12))
    print(value2(v))


main()

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
j, k = x2-x1, y2-y1
l, m = x3-x1, y3-y1
a = ( j**2 + k**2 )**0.5
b = ( l**2 + m**2 )**0.5
c = ( (j-l)**2 + (k-m)**2 )**0.5
S = abs(j*m-k*l)/2
T = (a+b+c)/2
M = max(a, b, c)
r = S / (2*S/M + T)
print(r)

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
d1, d2, d3 = sorted(((x2 - x3) ** 2 + (y2 - y3) ** 2,
                     (x1 - x3) ** 2 + (y1 - y3) ** 2,
                     (x1 - x2) ** 2 + (y1 - y2) ** 2), reverse=True)
d1 = d1 ** .5
d2 = d2 ** .5
d3 = d3 ** .5
s = abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2
r = 2 * s / (d1 + d2 + d3)
print(d1 / (2 + d1 / r))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
#import heapq
#from fractions import gcd
#from collections import defaultdict
#sys.setrecursionlimit(10**9)
#map(int,input().split())

def main():
    li=[list(map(int,input().split())) for i in range(3)]
    li.append(li[0])
    d=[0]*3
    for i in range(3):
        d[i]=((li[i][0]-li[i+1][0])**2+(li[i][1]-li[i+1][1])**2)**0.5
    dmax=max(d)
    dsum=sum(d)
    s=dsum/2
    S=(s*(s-d[0])*(s-d[1])*(s-d[2]))**0.5
    r=2*S/dsum
    print((r*dmax)/(2*r+dmax))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
s=abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a=((x1-x2)**2+(y1-y2)**2)**0.5
b=((x2-x3)**2+(y2-y3)**2)**0.5
c=((x3-x1)**2+(y3-y1)**2)**0.5
r=s/(a+b+c)
print(max(a,b,c)*r/(2*r+max(a,b,c)))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())

area=(1/2)*abs(a*f-a*d-c*f-b*e+d*e+b*c)
A=abs((a-c)**2+(b-d)**2)
A=A**(1/2)
B=abs((a-e)**2+(b-f)**2)
B=B**(1/2)
C=abs((e-c)**2+(f-d)**2)
C=C**(1/2)
print(max((2*A*area)/(4*area+A*(A+B+C)),(2*B*area)/(4*area+B*(A+B+C)),(2*C*area)/(4*area+C*(A+B+C))))

Submission status: Accepted

Solution code:
p = [[int(i) for i in input().split()] for i in range(3)]
a = []
for i in range(3): a.append((p[i][0]-p[(i+1)%3][0])**2+(p[i][1]-p[(i+1)%3][1])**2)
a.sort()
print(a[2]**0.5/
(((2*(a[0]*a[2])**0.5+a[0]+a[2]-a[1])/(2*(a[0]*a[2])**0.5-a[0]-a[2]+a[1]))**0.5+
((2*(a[1]*a[2])**0.5+a[1]+a[2]-a[0])/(2*(a[1]*a[2])**0.5-a[1]-a[2]+a[0]))**0.5+2))

Submission status: Accepted

Solution code:
from math import hypot
p = [list(map(int, input().split())) for i in range(3)]
x1 = p[1][0] - p[0][0]
y1 = p[1][1] - p[0][1]
x2 = p[2][0] - p[0][0]
y2 = p[2][1] - p[0][1]
s2 = abs(x1*y2-x2*y1)
s = 0
m = 0
for i in range(3):
    x = p[i-1][0]-p[i][0]
    y = p[i-1][1]-p[i][1]
    l = hypot(x, y)
    s += l
    m = max(m, l)
r = s2/s
x = m*r/(2*r+m)
print(x)

Submission status: Accepted

Solution code:
x1,y1 = map(int, input().split( ))
x2,y2 = map(int, input().split( ))
x3,y3 = map(int, input().split( ))

s2 = abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))

a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c =(x3-x2)**2+(y3-y2)**2

a **=(1/2)
b **=(1/2)
c **=(1/2)
mx = max(a,b,c)
h= s2/mx

h = s2/(a+b+c+2*h)
print(h)

Submission status: Accepted

Solution code:
# cf16-exhibition-final-openB - Inscribed Bicycle
def main():
    x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())
    a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
    b = ((x1 - x3) ** 2 + (y1 - y3) ** 2) ** 0.5
    c = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    x2 -= x1
    y2 -= y1
    x3 -= x1
    y3 -= y1
    a = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    b = (x3 ** 2 + y3 ** 2) ** 0.5
    c = (x2 ** 2 + y2 ** 2) ** 0.5
    r = abs(x2 * y3 - x3 * y2) / (a + b + c)
    d = max(a, b, c)
    ans = r * d / (2 * r + d)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x1, y1 = [int(_) for _ in input().split()]
x2, y2 = [int(_) for _ in input().split()]
x3, y3 = [int(_) for _ in input().split()]

x2 -= x1
y2 -= y1
x3 -= x1
y3 -= y1

A = ((x2 - x3)**2 + (y2 - y3)**2)**0.5
B = (x3**2 + y3**2)**0.5
C = (x2**2 + y2**2)**0.5
R = abs(x2 * y3 - x3 * y2) / (A + B + C)
#(R-x)/R=2x/D
#x=RD/(2R+D)
D = max(A, B, C)
x = R * D / (2 * R + D)
print(x)

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

def cos(x1, y1, x2, y2, x3, y3):
    x2 -= x1
    x3 -= x1
    y2 -= y1
    y3 -= y1
    return (x2*x3+y2*y3)/((x2**2+y2**2)**0.5 * (x3**2+y3**2)**0.5)

def tan(cos):
    return ((1-cos)/(1+cos))**0.5

def r(x1, y1, x2, y2, x3, y3):
    tan1 = tan(cos(x1, y1, x2, y2, x3, y3))
    tan2 = tan(cos(x3, y3, x1, y1, x2, y2))
    b = ((x1-x3)**2+(y1-y3)**2)**0.5
    return b*tan1*tan2 / (tan1+tan2+2*tan1*tan2)

r1 = r(x1, y1, x2, y2, x3, y3)
r2 = r(x2, y2, x3, y3, x1, y1)
r3 = r(x3, y3, x1, y1, x2, y2)
print(max([r1, r2, r3]))

Submission status: Accepted

Solution code:
import math
def cal0(x,y):
    return (x[0]-y[0])**2+(x[1]-y[1])**2
def cal(x,y):
    return math.sqrt(cal0(x,y))
A = list(map(float,input().split()))
B = list(map(float,input().split()))
C = list(map(float,input().split()))

a = cal(B,C)
b = cal(C,A)
c = cal(A,B)
s = (a+b+c)/2
d = math.sqrt(s*(s-a)*(s-b)*(s-c))
e = 2*d/(a+b+c)
f = max(a,max(b,c))
print(f/(2+f/e))

Submission status: Accepted

Solution code:
A=list(map(int,input().split()))
x1=A[0]
y1=A[1]
B=list(map(int,input().split()))
x2=B[0]
y2=B[1]
C=list(map(int,input().split()))
x3=C[0]
y3=C[1]
a=((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))**0.5
b=((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1))**0.5
c=((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3))**0.5
S=abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2
print(2*S/(a+b+c+4*S/(max(a,b,c))))

Submission status: Accepted

Solution code:
from math import hypot

x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())

a = hypot(x1 - x2, y1 - y2)
b = hypot(x2 - x3, y2 - y3)
c = hypot(x3 - x1, y3 - y1)
R = abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / (a + b + c)
m = max(a, b, c)
r = m / (2 + m / R)

print("{:.12f}".format(r))

Submission status: Accepted

Solution code:

xy = [list(map(int,input().split())) for _ in range(3)]

angle = [0]*3
import numpy as np
import math
ans = 0
for i in range(3):
    cnt = 0
    a = [[0,0] for _ in range(2)]
    for j in range(3):
        if j==i:continue
        a[cnt] = [xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]]
        cnt += 1
    val = (a[0][0]*a[1][0] + a[0][1]*a[1][1]) / (np.sqrt(a[0][0]**2 + a[0][1]**2)*np.sqrt(a[1][0]**2 + a[1][1]**2))
    theta = math.acos(val)
    angle[i] = theta/2
    
idx = [[1,2],[0,2],[0,1]]

for i in range(3):
    c = [xy[idx[i][0]][0] - xy[idx[i][1]][0],xy[idx[i][0]][1] - xy[idx[i][1]][1]]
    L = np.sqrt(c[0]**2 + c[1]**2)
    tmp = 0
    for j in range(3):
        if i==j:continue
        tmp += 1/np.tan(angle[j])
    r = L / (2 + tmp)
    ans = max(ans,r)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#CODEFESTIVAL2016 GrandFinal B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x1,y1 = LI()
x2,y2 = LI()
x3,y3 = LI()
s = abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a ,b, c = math.sqrt((x1-x2)**2+(y1-y2)**2),math.sqrt((x2-x3)**2+(y2-y3)**2),math.sqrt((x3-x1)**2+(y3-y1)**2)
r = s/(a+b+c)
ans = max(a,b,c)*r/(2*r+max(a,b,c))
print(ans)

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
v1 = x1 + y1 * 1j
v2 = x2 + y2 * 1j
v3 = x3 + y3 * 1j

v12 = v2 - v1
v13 = v3 - v1
s = abs(v12.real * v13.imag - v12.imag * v13.real) / 2
d12 = abs(v12)
d23 = abs(v3 - v2)
d13 = abs(v13)
r = 2 * s / (d12 + d23 + d13)
a = max(d12, d23, d13)
print(a * r / (2 * r + a))

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

def dist(x, y, u, v):
    return ((x - u)**2 + (y - v)**2)**0.5

a = dist(x1, y1, x2, y2)
b = dist(x2, y2, x3, y3)
c = dist(x3, y3, x1, y1)
s = (a + b + c) / 2

S = (s * (s - a) * (s - b) * (s - c))**0.5
leng = a + b + c
L = max(a, b, c)

r = S * 2 / leng
ans = r * L / (r + r + L)
print(ans)

Submission status: Accepted

Solution code:
import sys

x1,y1,x2,y2,x3,y3 = map(int,sys.stdin.read().split())

a,b = x2-x1,y2-y1
c,d = x3-x1,y3-y1

area = abs(a*d-b*c)/2
edge = (a*a+b*b)**.5, (c*c+d*d)**.5, ((a-c)**2+(b-d)**2)**.5

pelim = sum(edge)
r = area * 2 / pelim

L = max(edge)
answer = r*L/(r+r+L)
print(answer)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,open(0).read().split())
a,b,c=sorted((s*s+t*t)**.5for s,t in((a-c,b-d),(c-e,d-f),(e-a,f-b)))
d=a+b+c
s=d/2
s=(s*(s-a)*(s-b)*(s-c))**.5
print(c/(2+c/2/s*d))

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,open(0).read().split())
a,b,c=sorted((s*s+t*t)**.5for s,t in((a-c,b-d),(c-e,d-f),(e-a,f-b)))
d=a+b+c
s=d/2
s=(s*(s-a)*(s-b)*(s-c))**.5
r=2*s/d
l,h=0,1e5
while h-l>1e-9:
  m=(h+l)/2
  if c*(r-m)/r<2*m:h=m
  else:l=m
print(l)

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
a = (((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5
b = (((x3 - x2) ** 2) + ((y3 - y2) ** 2)) ** 0.5
c = (((x1 - x3) ** 2) + ((y1 - y3) ** 2)) ** 0.5
max_s = max(max(a, b), c)
s = (a + b + c) / 2
S = (s * (s - a) * (s - b) * (s - c)) ** 0.5
r = S / s
print(r * max_s / (max_s + (2 * r)))

Submission status: Accepted

Solution code:
l = [tuple(map(int,input().split())) for _ in range(3)]
s = abs((l[1][0]-l[0][0])*(l[2][1]-l[0][1]) - (l[1][1]-l[0][1])*(l[2][0]-l[0][0]))
a = ((l[1][0]-l[0][0])**2 + (l[1][1]-l[0][1])**2)**.5
b = ((l[2][0]-l[1][0])**2 + (l[2][1]-l[1][1])**2)**.5
c = ((l[2][0]-l[0][0])**2 + (l[2][1]-l[0][1])**2)**.5
t = max(a,b,c)
r = s/(a+b+c)
ng = r
ok = 0
for _ in range(80):
  mid = (ok+ng)/2
  if t*(1-mid/r) >= mid*2:
    ok = mid
  else:
    ng = mid
print("{:.12}".format(ok))

Submission status: Accepted

Solution code:
a=[list(map(int,input().split()))for i in range(3)]
s,t,u=((a[0][0]-a[1][0])**2+(a[0][1]-a[1][1])**2)**0.5,((a[2][0]-a[1][0])**2+(a[2][1]-a[1][1])**2)**0.5,((a[0][0]-a[2][0])**2+(a[0][1]-a[2][1])**2)**0.5
p=(s+t+u)/2
q=(p*(p-s)*(p-t)*(p-u))**0.5
r=2*q/(s+t+u)
g=max(s,t,u)
print(g/(2+g/r))

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

e12 = ((x2-x1)**2 + (y2-y1)**2)**0.5
e23 = ((x3-x2)**2 + (y3-y2)**2)**0.5
e31 = ((x1-x3)**2 + (y1-y3)**2)**0.5

s = (e12 + e23 + e31)/2
S = (s * (s-e12) * (s-e23) * (s-e31)) ** 0.5
r=2*S/(e12+e23+e31)
A=max(e12,e23,e31)
print(A*r/(2*r+A))

Submission status: Accepted

Solution code:
import math
xy = []
for i in range(3):
    xy.append([int(item) for item in input().split()])
xy.append(xy[0])

dist = []
for i in range(3):
    distance = math.sqrt((xy[i][0] - xy[i+1][0])**2.0 + (xy[i][1] - xy[i+1][1])**2.0)
    dist.append([distance, i, (i+1) % 3, (i+2) % 3])
dist.sort(reverse=True)

def get_vector(a, b):
    v = [a[0] - b[0], a[1] - b[1]]
    return v

def norm(a):
    n = math.sqrt(a[0] * a[0] + a[1] * a[1])
    return n

a = get_vector(xy[dist[0][-1]], xy[dist[0][-2]])
b = get_vector(xy[dist[0][-3]], xy[dist[0][-2]])
c = get_vector(xy[dist[0][-1]], xy[dist[0][-3]])
d = get_vector(xy[dist[0][-2]], xy[dist[0][-3]])
bc = dist[0][0]

ctheta = (a[0] * b[0] + a[1] * b[1]) / (norm(a) * norm(b))
cphi = (c[0] * d[0] + c[1] * d[1]) / (norm(c) * norm(d))
htheta = (math.pi - math.acos(ctheta)) / 2.0
hphi = (math.pi - math.acos(cphi)) / 2.0
r = bc / (math.tan(htheta) + math.tan(hphi) + 2)
print(r)

Submission status: Accepted

Solution code:
import math


def vec(p1, p2):
    return (p2[0] - p1[0], p2[1] - p1[1])


def l(v):
    return math.sqrt(v[0]**2 + v[1]**2)


def check(a, b, c, x, r):
    m = 1 - x/r
    return max([a, b, c]) * m >= x*2


def main():
    x = [0] * 3
    y = [0] * 3
    P = [None] * 3
    for i in range(3):
        x, y = map(int, input().split())
        P[i] = (x, y)
    v0 = vec(P[0], P[1])
    v1 = vec(P[0], P[2])
    v2 = vec(P[1], P[2])
    a = l(v0)
    b = l(v1)
    c = l(v2)
    r = abs(v0[0] * v1[1] - v0[1] * v1[0]) / (a + b + c)
    lo = 0.0
    hi = r
    while hi - lo >= 1e-10:
        mid = (hi + lo) / 2
        if check(a, b, c, mid, r):
            lo = mid
        else:
            hi = mid
    print(lo)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np
P = np.array([list(map(int,input().split())) for _ in [0]*3],dtype=float)

def f(r):
    R = 0+P
    for i in range(3):
        c = r / (1 - e[i].dot(e[i-1])**2)**0.5
        R[i] += c*(e[i]-e[i-1])
    return R

def g(p):
    r = 0
    n = np.linalg.norm
    for i in range(3):
        r = max(r,n(p[i]-p[i-1]))
    return r

def h(r):return g(f(r))<2*r

def binary_search_float(l,r,func,d):
    if func(l):return l
    if not func(r):return r
    while (r-l)>=d:
        i = (l+r)/2
        if func(i):
            r = i
        else:
            l = i
    return l

e = -P
for i in range(3):
    e[i] += P[(i+1)%3]
l = np.linalg.norm(e,axis=1)
L = np.sum(l)
S2 = np.abs(e[0,0]*e[-1,1]-e[-1,0]*e[0,1])
M = S2/L
e = e/(l*np.ones((2,3))).T

print(binary_search_float(0,M,h,1e-10))

Submission status: Accepted

Solution code:
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

def Area(dots):
	res = 0
	for i in range(len(dots)-1):
		res += OuterProduct(dots[i], dots[i+1])
	res += OuterProduct(dots[-1], dots[0])
	return res/2

d = [list(map(int, input().split())) for _ in range(3)]
x = complex(d[0][0], d[0][1])
y = complex(d[1][0], d[1][1])
z = complex(d[2][0], d[2][1])
s = abs(Area([x, y, z]))
a, b, c = abs(x-y), abs(y-z), abs(z-x)
print(2*s/(a+b+c+(4*s/max(a, b, c))))

Submission status: Accepted

Solution code:
xy = [list(map(int, input().split())) for _ in range(3)]
s = abs((xy[1][0]-xy[0][0])*(xy[2][1]-xy[0][1]) - (xy[1][1]-xy[0][1])*(xy[2][0]-xy[0][0])) / 2
a = ((xy[1][0]-xy[0][0])**2 + (xy[1][1]-xy[0][1])**2)**0.5
b = ((xy[2][0]-xy[0][0])**2 + (xy[2][1]-xy[0][1])**2)**0.5
c = ((xy[2][0]-xy[1][0])**2 + (xy[2][1]-xy[1][1])**2)**0.5
print(1/(2/max(a, b, c) + (a+b+c)/s/2))

Submission status: Accepted

Solution code:
x0,y0=map(int,input().split())
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
def make_dist(i,j,k,l):
    return ((i-k)**2+(j-l)**2)**0.5
a=y1-y2
b=x2-x1
c=x1*y2-y1*x2
d12=make_dist(x1,y1,x2,y2)
d01=make_dist(x0,y0,x1,y1)
d02=make_dist(x0,y0,x2,y2)
S_double=d12*abs(a*x0+b*y0+c)/(make_dist(a,b,0,0))
r=S_double/(d01+d02+d12)
d=max(d01,d02,d12)
ans=d*r/(2*r+d)
print(ans)

Submission status: Accepted

Solution code:
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    A = list(map(int, line_input()))
    B = list(map(int, line_input()))
    C = list(map(int, line_input()))

    ab = round(math.sqrt(pow(A[0] - B[0], 2) + pow(A[1] - B[1], 2)), 15)
    bc = round(math.sqrt(pow(B[0] - C[0], 2) + pow(B[1] - C[1], 2)), 15)
    ca = round(math.sqrt(pow(C[0] - A[0], 2) + pow(C[1] - A[1], 2)), 15)
    S = round(abs((C[0] - A[0]) * (C[1] - B[1]) - (C[1] - A[1]) * (C[0] - B[0])) / 2, 15)
    r = round(S * 2 / (ab + bc + ca), 15)
    longest_side = max([ab, bc, ca])

    x = round(longest_side * r / (2 * r + longest_side),14)
    return x
 
if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
from math import hypot, sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def heron(a, b, c):
    s=(a+b+c)/2
    return sqrt(s*(s-a)*(s-b)*(s-c))

x1,y1=MAP()
x2,y2=MAP()
x3,y3=MAP()

# 各辺の長さ
a=hypot(x1-x2, y1-y2)
b=hypot(x2-x3, y2-y3)
c=hypot(x3-x1, y3-y1)
# 三角形の面積(ヘロンの公式)
S=heron(a, b, c)
# 内接円の半径
r=2*S/(a+b+c)

# max(a,b,c)*(1-x/r)==2*xをxについて解く
mx=max(a, b, c)
print(mx/(2+mx/r))

Submission status: Accepted

Solution code:
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
c1,c2 = map(int,input().split())

C = ((a1-b1)**2 + (a2-b2)**2)**(1/2)
A = ((b1-c1)**2 + (b2-c2)**2)**(1/2)
B = ((c1-a1)**2 + (c2-a2)**2)**(1/2)

S = abs((b1-a1)*(c2-a2)-(b2-a2)*(c1-a1))

r1 = B*S/(B*(A + B + C) + 2*S)
r2 = C*S/(C*(A + B + C) + 2*S)
r3 = A*S/(A*(A + B + C) + 2*S)

print(max(r1,r2,r3))

Submission status: Accepted

Solution code:
from math import acos, tan, hypot

def getRad1(s12, s13, s23):
    return acos((s12*s12 + s13*s13 - s23*s23) / (2*s12*s13))

def getMaxR(s12, rad1, rad2):
    tan1 = tan(rad1 / 2)
    tan2 = tan(rad2 / 2)
    h = s12 * (tan1*tan2) / (tan1+tan2)

    def isOK(mid):
        return s12 - mid/tan1 - mid/tan2 <= 2*mid

    ng, ok = 0, h
    while abs(ok-ng) > 10**-12:
        mid = (ng+ok) / 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    return ok

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

s12 = hypot(x1-x2, y1-y2)
s23 = hypot(x2-x3, y2-y3)
s31 = hypot(x3-x1, y3-y1)

rad1 = getRad1(s12, s31, s23)
rad2 = getRad1(s23, s12, s31)
rad3 = getRad1(s31, s23, s12)

maxRs = [
    getMaxR(s12, rad1, rad2), 
    getMaxR(s23, rad2, rad3),
    getMaxR(s31, rad3, rad1)
]
print(max(maxRs))

Submission status: Accepted

Solution code:
from math import acos, tan, hypot

def getRad1(s12, s13, s23):
    return acos((s12*s12 + s13*s13 - s23*s23) / (2*s12*s13))

def getMaxR(s12, rad1, rad2):
    tan1 = tan(rad1 / 2)
    tan2 = tan(rad2 / 2)
    h = s12 * (tan1*tan2) / (tan1+tan2)
    return h * (tan1+tan2) / (2*tan1*tan2 + tan1 + tan2)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

s12 = hypot(x1-x2, y1-y2)
s23 = hypot(x2-x3, y2-y3)
s31 = hypot(x3-x1, y3-y1)

rad1 = getRad1(s12, s31, s23)
rad2 = getRad1(s23, s12, s31)
rad3 = getRad1(s31, s23, s12)

maxRs = [
    getMaxR(s12, rad1, rad2), 
    getMaxR(s23, rad2, rad3),
    getMaxR(s31, rad3, rad1)
]
print(max(maxRs))

Submission status: Accepted

Solution code:
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())


d1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
d2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
d3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
D = max(d1, d2, d3)


s = (d1 + d2 + d3) / 2
S = (s * (s - d1) * (s - d2) * (s - d3)) ** 0.5
R = (2 * S) / (d1 + d2 + d3)


ok, ng = 0, 10000
eps = 1e-9

while abs(ok - ng) > eps:
    r = (ok + ng) / 2
    if 2 * r <= D * ((R - r) / R):
        ok = r
    else:
        ng = r

print(ok)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import sqrt

points = [tuple(li()) for _ in range(3)]

# 3つの辺を求める
sides = []
angles = []
for i in range(3):
    p1,p2 = points[i], points[(i+1)%3]
    sides.append(sqrt((p2[0]-p1[0])**2 + (p2[1]-p1[1])**2))

# 内接円の半径
s = (sum(sides)) / 2
a,b,c = sides
area = sqrt(s* (s-a) * (s-b) * (s-c))
r = 2*area / sum(sides)

print(max(sides)*r / (2*r + max(sides)))

Submission status: Accepted

Solution code:
Tri=[]
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
a1,a2=x2-x1,y2-y1
b1,b2=x3-x1,y3-y1
c1,c2=x3-x2,y3-y2
S=abs(a1*b2-a2*b1)/2
a=(a1**2+a2**2)**(1/2)
b=(b1**2+b2**2)**(1/2)
c=(c1**2+c2**2)**(1/2)
h=2*S/max(a,b,c)
r=S/(h+(a+b+c)/2)
print(r)