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: Accepted

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

A = ((x1-x2)**2+(y1-y2)**2)**(1/2)
B = ((x2-x3)**2+(y2-y3)**2)**(1/2)
C = ((x3-x1)**2+(y3-y1)**2)**(1/2)
S = A+B+C
A, C = max(A, B, C), min(A, B, C)
B = S-A-C

cosb = (A**2+C**2-B**2)/2/A/C
cosc = (A**2+B**2-C**2)/2/A/B

R = A/(2 + ( (1+cosb) / (1-cosb) )**(1/2) + ( (1+cosc) / (1-cosc) )**(1/2) )
print(R)

Submission status: Accepted

Solution code:
import math
table=[[int(i) for i in input().split()] for i in range(3)]
r=[0]*3
for i in range(3):
    a=(table[i%3][0]-table[(i+1)%3][0])**2
    b=(table[i%3][1]-table[(i+1)%3][1])**2
    r[i]=math.sqrt(a+b)
s=sum(r)/2
t=s
for i in range(3):
    t*=(s-r[i])
t=math.sqrt(t)
x=t*2/(sum(r))
u=max(r)
print(x*u/(2*x+u))

Submission status: Accepted

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

from math import sqrt

d1=sqrt((x2-x3)**2+(y2-y3)**2)
d2=sqrt((x1-x3)**2+(y1-y3)**2)
d3=sqrt((x1-x2)**2+(y1-y2)**2)

l=max(d1,max(d2,d3))

def cos(x,y,z):
    return (y**2+z**2-x**2)/(2*y*z)

c1=cos(d1,d2,d3)
c2=cos(d2,d1,d3)
c3=cos(d3,d2,d1)

c1=sqrt((1+c1)/2)
c2=sqrt((1+c2)/2)
c3=sqrt((1+c3)/2)

ct1=sqrt(1/(1/(c1**2)-1))
ct2=sqrt(1/(1/(c2**2)-1))
ct3=sqrt(1/(1/(c3**2)-1))

r=max(d1/(2+ct2+ct3),max(d2/(2+ct1+ct3),d3/(2+ct2+ct1)))

print(r)

Submission status: Accepted

Solution code:
def norm(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5
def d(a, b, c, x, y):
    return abs(a*x + b*y + c) / (a**2 + b**2)**0.5
def points2line(x1, y1, x2, y2):
    la = y1 - y2
    lb = x2 - x1
    lc = x1 * (y2 - y1) + y1 * (x1 - x2)
    return la, lb, lc
from numpy import argmax
#def argmax(L):
#    return max(enumerate(L), key=lambda x: x[1])[0]

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

a = norm(x3, y3, x2, y2)
b = norm(x1, y1, x3, y3)
c = norm(x1, y1, x2, y2)

xc = (a*x1 + b*x2 + c*x3)/(a+b+c)
yc = (a*y1 + b*y2 + c*y3)/(a+b+c)

iw = argmax([a, b, c])
w = [a, b, c][int(iw)]

L = [[x1, y1], [x2, y2], [x3, y3]]
del L[int(iw)]
m, n = L[0]
p, q = L[1]
s, t, u = points2line(m, n, p, q)
h = d(s, t, u, xc, yc)
print(w*h/(2*h + w))

Submission status: Accepted

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)
    s = (a + b + c) / 2
    area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
    r = 2 * area / (a + b + c)
    m = max(a,b,c)
    return m/(2+m/r)


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

Submission status: Accepted

Solution code:
xy = [list(map(int, input().split())) for _ in range(3)]
d = [((xy[i][0] - xy[i + 1][0]) ** 2 + (xy[i][1] - xy[i + 1][1]) ** 2) ** .5
     for i in range(-1, 2)]
s = abs((xy[1][0] - xy[0][0]) * (xy[2][1] - xy[0][1])
        -(xy[2][0] - xy[0][0]) * (xy[1][1] - xy[0][1])) / 2

k = max(d)
r = 2 * s / sum(d)
x = k * r / (k + 2 * r)
print('{:.10f}'.format(x))

Submission status: Accepted

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

# 3辺の長さとその最大値
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
L = max(a, b, c)

# ヘロンの公式
s = (a + b + c) / 2
S = (s * (s - a) * (s - b) * (s - c)) ** 0.5

# 内接円の半径
r = (2 * S) / (a + b + c)

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

Submission status: Accepted

Solution code:
import math
ps = [tuple(map(int,input().split())) for i in range(3)]

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return math.hypot(x1-x2, y1-y2)

es = [dist(ps[0],ps[1]), dist(ps[1],ps[2]), dist(ps[2],ps[0])]
longest = max(es)

#Heron
s = sum(es) / 2
area = math.sqrt(s * (s-es[0]) * (s-es[1]) * (s-es[2]))

h = 2 * area / longest
r = (longest * h) / (sum(es) + 2*h)
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())
xa=x2-x1
ya=y2-y1
xb=x3-x1
yb=y3-y1

S=abs(xa*yb-xb*ya)/2
a=(xb*xb+yb*yb)**0.5
b=(xa*xa+ya*ya)**0.5
c=((xa-xb)**2+(ya-yb)**2)**0.5

R=max(2*S/(a+b+c+4*S/a),2*S/(a+b+c+4*S/b),2*S/(a+b+c+4*S/c))

print(R)

Submission status: Accepted

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

points = (m.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in zip((p1, p2, p3), (p2, p3, p1)))
a, b, c = sorted(points)
s = (a + b + c) / 2
T = m.sqrt(s*(s-a)*(s-b)*(s-c))
ans = 2*T / (a + b + c + 4*T/c)
print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
P = [map(int, raw_input().split()) for i in [0,1,2]]
def dist(p, q):
    return sqrt((p[0]-q[0])**2 + (p[1]-q[1])**2)
D = [dist(P[i-1], P[i]) for i in xrange(3)]
D = D*2

def rtanhalf(a, b, c):
    p = 2*a*b
    q = a**2 + b**2 - c**2
    return sqrt(float(q + p) / float(p - q))
def solve(a, b, c):
    s = rtanhalf(a, b, c)
    t = rtanhalf(c, b, a)
    r = b / (2. + s + t)
    return r
print max(solve(*D[i:i+3]) for i in xrange(3))

Submission status: Runtime Error

Solution code:
def norm(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5
def d(a, b, c, x, y):
    return abs(a*x + b*y + c) / (a**2 + b**2)**0.5
def points2line(x1, y1, x2, y2):
    la = y1 - y2
    lb = x2 - x1
    lc = x1 * (y2 - y1) + y1 * (x1 - x2)
    return la, lb, lc
#from numpy import argmax
def argmax(L):
    return max(enumerate(L), key=lambda x: x[1])[0]

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

a = norm(x3, y3, x2, y2)
b = norm(x1, y1, x3, y3)
c = norm(x1, y1, x2, y2)

xc = (a*x1 + b*x2 + c*x3)/(a+b+c)
yc = (a*y1 + b*y2 + c*y3)/(a+b+c)

iw = argmax([a, b, c])
w = [a, b, c][int(iw)]

L = [[x1, y1], [x2, y2], [x3, y3]]
del L[int(iw)]
h = d(*points2line(*L[0], *L[1]), xc, yc)
print(w*h/(2*h + w))

Submission status: Runtime Error

Solution code:
def norm(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5
def d(a, b, c, x, y):
    return abs(a*x + b*y + c) / (a**2 + b**2)**0.5
def points2line(x1, y1, x2, y2):
    la = y1 - y2
    lb = x2 - x1
    lc = x1 * (y2 - y1) + y1 * (x1 - x2)
    return la, lb, lc
from numpy import argmax

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

a = norm(x3, y3, x2, y2)
b = norm(x1, y1, x3, y3)
c = norm(x1, y1, x2, y2)

xc = (a*x1 + b*x2 + c*x3)/(a+b+c)
yc = (a*y1 + b*y2 + c*y3)/(a+b+c)

iw = argmax([a, b, c])
w = [a, b, c][int(iw)]

L = [[x1, y1], [x2, y2], [x3, y3]]
del L[int(iw)]
h = d(*points2line(*L[0], *L[1]), xc, yc)
print(w*h/(2*h + w))

Submission status: Runtime Error

Solution code:
def norm(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5
def d(a, b, c, x, y):
    return abs(a*x + b*y + c) / (a**2 + b**2)**0.5
def points2line(x1, y1, x2, y2):
    la = y1 - y2
    lb = x2 - x1
    lc = x1 * (y2 - y1) + y1 * (x1 - x2)
    return la, lb, lc
from numpy import argmax

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

a = norm(x3, y3, x2, y2)
b = norm(x1, y1, x3, y3)
c = norm(x1, y1, x2, y2)

xc = (a*x1 + b*x2 + c*x3)/(a+b+c)
yc = (a*y1 + b*y2 + c*y3)/(a+b+c)

iw = argmax([a, b, c])
w = [a, b, c][iw]

L = [[x1, y1], [x2, y2], [x3, y3]]
del L[iw]
h = d(*points2line(*L[0], *L[1]), xc, yc)
print(w*h/(2*h + w))

Submission status: Runtime Error

Solution code:
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: Runtime Error

Solution code:
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))
xs = 0
oc = 0
for x in a:
   xs ^= x >> 1
   oc ^= x & 1

if xs:
   print -1
else:
   print oc