Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Circumscribed Circle of A Triangle.

Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. 

Input

Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:

$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$

in a line. All the input are real numbers.

Output

For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.

Constraints

$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$

$ n \leq 20$

Sample Input

1
0.0 0.0 2.0 0.0 2.0 2.0

Output for the Sample Input

1.000 1.000 1.414



Sample input:
1
0.0 0.0 2.0 0.0 2.0 2.0


Sample output:
1.000 1.000 1.414

Submission status: Wrong Answer

Solution code:
def perpendicular_bisector(p, q):
    x = (q[0] - p[0])
    y = (q[1] - p[1])
    return (2 * x, 2 * y, p[0]**2-q[0]**2+p[1]**2-q[1]**2)


def gauss_jordan_elimination(Array):
    # N???M??????Array
    N = len(Array)
    if N == 0:
        return (True, Array)
    else:
        M = len(Array[0])

    A = []
    for i in range(len(Array)):
        A.append(Array[i][:])

    pivot = 0
    L = min(N, M)
    while pivot < L:
        pivot_v = A[pivot][pivot]
        pivot_row = pivot
        for i in range(pivot + 1, L):
            v = max(A[i][pivot], -A[i][pivot])
            if pivot_v < v:
                pivot_row = i
                pivot_v = v
        if pivot_row > pivot:
            for i in range(M):
                A[pivot][i], A[pivot_row][i] = A[pivot_row][i], A[pivot][i]
        if pivot_v == 0:
            return ('False', A)
        inv_pivot = 1 / A[pivot][pivot]
        A[pivot][pivot] = 1
        for i in range(pivot + 1, M):
            A[pivot][i] *= inv_pivot
        for i in range(N):
            if i == pivot:
                continue
            t = -1 * A[i][pivot]
            A[i][pivot] = 0
            for j in range(pivot + 1, M):
                A[i][j] += t * A[pivot][j]
        pivot += 1
    return ('True', A)

n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    a = list(perpendicular_bisector((x1, y1), (x2, y2)))
    b = list(perpendicular_bisector((x1, y1), (x3, y3)))
    c = [a, b]
    state, c = gauss_jordan_elimination(c)
    x = c[0][2]
    y = c[1][2]
    r = ((x - x1)**2 + (y - y1)**2)**0.5
    print('{0:.3f} {1:.3f} {2:.3f}'.format(-round(x, 3), -round(y, 3), round(r, 3)))

Submission status: Wrong Answer

Solution code:
from math import sqrt

def circle(x1, y1, x2, y2, x3, y3):
    if x1 == 0:
        dx = 1
        x1 = x1 + dx
        x2 = x2 + dx
        x3 = x3 + dx
    else:
        dx = 0
    if y2 == 0:
        dy = 1
        y1 = y1 + dy
        y2 = y2 + dy
        y3 = y3 + dy
    else:
        dy = 0
    A = [[x1, y1, 1, 1, 0, 0],[x2, y2, 1, 0, 1, 0],[x3, y3, 1, 0, 0, 1]]
#    print(A)
    for i in range(3):
        A[0] = [x/A[0][0] for x in A[0]]
        A[1] = [A[1][j] - A[1][0] * A[0][j] for j in range(6)]
        A[2] = [A[2][j] - A[2][0] * A[0][j] for j in range(6)]
#        print(A)
        for j in range(3):
            A[j] = A[j][1:] + A[j][:1]
        A = A[1:] + A[:1]
#        print(A)
    for i in range(3):
        A[i] = A[i][:3]
#    print(A)
    V = [-x1**2-y1**2, -x2**2-y2**2, -x3**2-y3**2]
    M = [(A[i][0] * V[0] + A[i][1] * V[1] + A[i][2] * V[2]) for i in range(3)]
    xcenter = -0.5 * M[0] - dx
    ycenter = -0.5 * M[1] - dy
    radius = sqrt((M[0]**2) /4 + (M[1]**2) /4 - M[2])
    return xcenter, ycenter, radius

n = int(input())
for line in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    xc, yc, ra = circle(x1, y1, x2, y2, x3, y3)
    print(xc, yc,ra)

Submission status: Wrong Answer

Solution code:
from math import sin,cos,sqrt
n=int(input())
out=[]
for i in range(n):
	I=list(map(float,input().split(" ")))
	#( (x_0,y_0), (x_1,y_1) , (x_2,y_2) )
	a_1=I[2]-I[0] #x_1-x_0
	a_2=I[4]-I[0] #x_2-x_0
	b_1=I[3]-I[1] #y_1-y_0
	b_2=I[5]-I[1] #y_2-y_0
	#print(a_1,b_1,a_2,b_2)

	K=(a_2**2 -a_2*b_2+a_1**2-a_1*b_1)/(a_2*b_1-a_1*b_2)

	O_x=0.5*(b_1-K*b_2)
	O_y=0.5*(b_2+K*b_1)
	O_R=sqrt( (I[0]-O_x)**2  + (I[1]-O_y)**2 )

	out.append( '{:.3f} {:.3f} {:.3f}'.format(O_x,O_y,O_R) )



for i in out:
	print(i)

Submission status: Wrong Answer

Solution code:
from math import sqrt
n=int(input())
out=[]
for i in range(n):
	I=list(map(float,input().split(" ")))
	#( (x_0,y_0), (x_1,y_1) , (x_2,y_2) )
	a_1=I[2]-I[0] #x_1-x_0
	a_2=I[4]-I[0] #x_2-x_0
	b_1=I[3]-I[1] #y_1-y_0
	b_2=I[5]-I[1] #y_2-y_0
	#print(a_1,b_1,a_2,b_2)

	K=(a_2**2 -a_2*b_2+a_1**2-a_1*b_1)/(a_2*b_1-a_1*b_2)

	O_x=0.5*(b_1-K*b_2)
	O_y=0.5*(b_2+K*b_1)
	O_R=sqrt( (I[0]-O_x)**2  + (I[1]-O_y)**2 )

	out.append( '{:.3f} {:.3f} {:.3f}'.format(O_x,O_y,O_R) )



for i in out:
	print(i)

Submission status: Wrong Answer

Solution code:
from math import sin,cos,sqrt
n=int(input())
out=[]
for i in range(n):
	I=list(map(float,input().split(" ")))
	#( (x_0,y_0), (x_1,y_1) , (x_2,y_2) )
	a_1=I[2]-I[0] #x_1-x_0
	a_2=I[4]-I[0] #x_2-x_0
	b_1=I[3]-I[1] #y_1-y_0
	b_2=I[5]-I[1] #y_2-y_0

	K=(a_2**2 -a_2*b_2+a_1**2-a_1*b_1)/(a_2*b_1-a_1*b_2)

	O_x=0.5*(b_1-K*b_2)
	O_y=0.5*(b_2+K*b_1)
	O_R=sqrt( (I[0]-O_x)**2  + (I[1]-O_y)**2 )
	
	print('{:.3f} {:.3f} {:.3f}'.format(O_x,O_y,O_R))
#	out.append( '{:.3f} {:.3f} {:.3f}'.format(O_x,O_y,O_R) )



#	for i in out:
#		print(i)

Submission status: Wrong Answer

Solution code:
import math

def solve(a,b,c,d,e,f):
	x = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))
	y = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))
	r = math.hypot(x-a, y-b) 
	return x,y,r

n = int(input())
for _ in range(n):
	a,b,c,d,e,f = map(float, input().split())
	x,y,r = solve(a,b,c,d,e,f)
	x += 0.0005
	y += 0.0005
	r += 0.0005
	print("{:.3f} {:.3f} {:.3f}".format(x, y, r))

Submission status: Wrong Answer

Solution code:
import math
x1=0
y1=1
x2=2
y2=3
x3=4
y3=5
n = input()
for _ in xrange(n):
    p = map(float, raw_input().split())
    A = p[x1]**2 - p[x2]**2 + p[y1]**2 - p[y2]**2
    B = 2*p[x1] - 2*p[x2]
    C = 2*p[y1] - 2*p[y2]
    D = p[x1]**2 - p[x3]**2 + p[y1]**2 - p[y3]**2
    E = 2*p[x1] - 2*p[x3]
    F = 2*p[y1] - 2*p[y3]
    if (C*E-B*F) == 0 or (B*E)==0:
        print "0.000 0.000 0.000"
        continue
    b = (A*E-D*B)/(C*E-B*F)
    a = (A*E-C*E*b)/(B*E)
    r = math.sqrt( (p[x1]-a)**2 + (p[y1]-b)**2 )
    print "%.3f %.3f %.3f" % (round(a, 3), round(b, 3), round(r, 3))

Submission status: Wrong Answer

Solution code:
def simultaneous_equasion(a, b, c, d, e, f):
    "??£???????¨????"
    det = a * d - b * c
    a11 = d / det
    a12 = - b / det
    a21 = - c / det
    a22 = a / det
    return a11 * e + a12 * f, a21 * e + a22 * f

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    # (x1, y1), (x2, y2)????????´????????????
    # 2 * (x2 - x1) * x + 2 * (y2 - y1) * y = (y2 - y1) ^ 2 + (x2 - x1) ^ 2
    a = 2 * (x2 - x1)
    b = 2 * (y2 - y1)
    c = 2 * (x3 - x1)
    d = 2 * (y3 - y1)
    e = (y2 - y1) ** 2 + (x2 - x1) ** 2
    f = (y3 - y1) ** 2 + (x3 - x1) ** 2
    px, py = simultaneous_equasion(a, b, c, d, e, f)
    print("%.3f %3f" % (round(px, 3), round(py, 3)))

Submission status: Wrong Answer

Solution code:
import math

def simultaneous_equasion(a, b, c, d, e, f):
    "??£???????¨????"
    det = a * d - b * c
    a11 = d / det
    a12 = - b / det
    a21 = - c / det
    a22 = a / det
    return a11 * e + a12 * f, a21 * e + a22 * f

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    # (x1, y1), (x2, y2)????????´????????????
    # 2 * (x2 - x1) * x + 2 * (y2 - y1) * y = (y2 - y1) ^ 2 + (x2 - x1) ^ 2
    a = 2 * (x2 - x1)
    b = 2 * (y2 - y1)
    c = 2 * (x3 - x1)
    d = 2 * (y3 - y1)
    e = (y2 - y1) ** 2 + (x2 - x1) ** 2
    f = (y3 - y1) ** 2 + (x3 - x1) ** 2
    px, py = simultaneous_equasion(a, b, c, d, e, f)
    r = math.sqrt((px - x1) ** 2 + (py - y1) ** 2)
    print("%.3f %.3f %.3f" % (round(px, 3), round(py, 3), round(r, 3)))

Submission status: Wrong Answer

Solution code:
import math

def da(li):
    x1,y1,x2,y2,x3,y3=[float(i) for i in li]
    xp,yp=(x2-x1)/2,(y2-y1)/2
    xq,yq=(x3-x1)/2,(y3-x1)/2
    t=(xq**2+yq**2-xp*xq-yp*yq)/(xp*yq-xq*yp)
    return xp-t*yp,yp+t*xp
def sis(fl):
    fls=str(fl)
    if len(fls)<6:return fls+"".join(["0" for i in range(5-len(fls))])
    if int(fls[5:6])>4:
        return fls[:4]+str(int(fls[4:5])+1)
    else:
        return fls[:5]

n=int(input())
for i in range(n):
    li=input().split(" ")
    x,y=da(li)
    print(sis(x)+" "+sis(y)+" "+sis(math.sqrt(x**2+y**2)))

Submission status: Wrong Answer

Solution code:
import math

def da(li):
    x1,y1,x2,y2,x3,y3=[float(i) for i in li]
    xp,yp=(x2-x1)/2,(y2-y1)/2
    xq,yq=(x3-x1)/2,(y3-x1)/2
    t=(xq**2+yq**2-xp*xq-yp*yq)/(xp*yq-xq*yp)
    return x1+xp-t*yp,y1+yp+t*xp
def sis(fl):
    fls=str(fl)
    if len(fls)<6:return fls+"".join(["0" for i in range(5-len(fls))])
    if int(fls[5:6])>4:
        return fls[:4]+str(int(fls[4:5])+1)
    else:
        return fls[:5]

n=int(input())
for i in range(n):
    li=input().split(" ")
    x,y=da(li)
    print(sis(x)+" "+sis(y)+" "+sis(math.sqrt(x**2+y**2)))

Submission status: Wrong Answer

Solution code:
import math

def da(li):
    x1,y1,x2,y2,x3,y3=[float(i) for i in li]
    xp,yp=(x2-x1)/2,(y2-y1)/2
    xq,yq=(x3-x1)/2,(y3-x1)/2
    t=(xq**2+yq**2-xp*xq-yp*yq)/(xp*yq-xq*yp)
    return x1-(xp-t*yp),y1-(yp+t*xp)
def sis(fl):
    fls=str(fl)
    if len(fls)<6:return fls+"".join(["0" for i in range(5-len(fls))])
    if int(fls[5:6])>4:
        return fls[:4]+str(int(fls[4:5])+1)
    else:
        return fls[:5]

n=int(input())
for i in range(n):
    li=input().split(" ")
    x,y=da(li)
    print(sis(x)+" "+sis(y)+" "+sis(math.sqrt(x**2+y**2)))

Submission status: Wrong Answer

Solution code:
from math import sqrt, fabs


def calcu_cirucumcenter(x1, y1, x2, y2, x3, y3):
    """
   ??????O?????§?¨????(x, y)??¨????????¨
   (x-x1)**2 + (y-y1)**2 = (x-x2)**2 + (y-y2)**2
   x**2 -2*x1*x + x1**2 + y**2 -2*y1*y + y1**2 = ... -2*x2*x, x2**2, -2*y2*y, y2**2
   ?????¨????????¨ (-2*x1 + 2*x2)x + (-2y1 + 2*y2)y + (x1**2 + y1**2 - x2**2 - y2**2) = 0
   x1, x3???????????????????§????
   (-2*x1 + 2*x3)x + (-2y1 + 2*y3)y + (x1**2 + y1**2 - x3**2 - y3**2) = 0
   """
    a = -2 * x1 + 2 * x2
    b = -2 * y1 + 2 * y2
    c = -2 * x1 + 2 * x3
    d = -2 * y1 + 2 * y3
    e = -1* (x1 ** 2 + y1 ** 2 - x2 ** 2 - y2 ** 2)
    f = -1 * (x1 ** 2 + y1 ** 2 - x3 ** 2 - y3 ** 2)

    x = 1 / (a * d - b * c) * (d * e - b * f)
    y = 1 / (a * d - b * c) * (-c * e + a * f)
    return x, y


if __name__ == '__main__':
    epsilon = 1e-9

    # ??????????????\???
    num = int(input())
    for i in range(num):
        x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split(' ')]

        # ?????\????????????(??????)????±???????
        x, y = calcu_cirucumcenter(x1, y1, x2, y2, x3, y3)
        # ?¨????????????¨?????? -0.0 ???????????´???????????¶?????? 0.0 ?????????
        if fabs(x) < epsilon:
            x = 0.0
        if fabs(y) < epsilon:
            y = 0.0

        # ????????????????????§????????¢?????????
        r = sqrt((x - x1)**2 + (x - y1)**2)

        print('{0:.3f} {1:.3f} {2:.3f}'.format(x, y, r))

Submission status: Wrong Answer

Solution code:
import sys
import math

def to_f(e):
  return float(e)

n = int(raw_input().rstrip())
for i in range(n):
  line = raw_input().rstrip() 
  x1, y1, x2, y2, x3, y3 = map(to_f, line.split(" "))
  a1 = 2*(x2-x1)
  a2 = 2*(x3-x1)
  b1 = 2*(y2-y1)
  b2 = 2*(y3-y1)
  c1 = x1**2-x2**2+y1**2-y2**2
  c2 = x1**2-x3**2+y1**2-y3**2
  xp = (b1*c2-b2*c1)/(a1*b2-a2*b1)
  yp = (c1*a2-c2*a1)/(a1*b2-a2*b1)
  r  = math.sqrt((xp-1)**2+(yp-y1)**2)
  print("{0:.3f} {0:.3f} {0:.3f}".format(xp, yp, r))

Submission status: Wrong Answer

Solution code:
from math import sqrt
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3= map(float, input().split())
    a= sqrt((x3-x2)**2 + (y3-y2)**2)
    b= sqrt((x3-x1)**2 + (y3-y1)**2)
    c= sqrt((x2-x1)**2 + (y2-y1)**2)
    numerator, denominator= 2*b*c, b**2 + c**2 - a**2
    cosA= denominator / numerator
    sinA= sqrt(1 - (cosA)**2)
    r= a / (2*sinA)
    px= (x2-x1) / 2
    py= (y3-y1) / 2
    print(px, py, r)

Submission status: Wrong Answer

Solution code:
from math import sqrt
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3= map(float, input().split())
    a= sqrt((x3-x2)**2 + (y3-y2)**2)
    b= sqrt((x3-x1)**2 + (y3-y1)**2)
    c= sqrt((x2-x1)**2 + (y2-y1)**2)
    numerator, denominator= 2*b*c, b**2 + c**2 - a**2
    cosA= denominator / numerator
    sinA= sqrt(1 - (cosA)**2)
    r= a / (2*sinA)
    px= (x2-x1) / 2
    py= (y3-y1) / 2
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))

Submission status: Wrong Answer

Solution code:
from math import sqrt
n = int(input())

for i in range(n):
    l = input()
    x1,y1,x2,y2,x3,y3=map(float,l.split(' '))
    a_2 = (x1 - x2)**2 + (y1 - y2)**2
    b_2 = (x2 - x3)**2 + (y2 - y3)**2
    c_2 = (x3 - x1)**2 + (y3 - y1)**2
    cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2)
    sin_a_2 = 1 - cos_a_2
    r = round(sqrt(a_2/sin_a_2)/2,3)
    a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1)
    b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1)
    c = (y2 - y1)*(x3 - x1)
    d = (y3 - y1)*(x2 - x1)
    py = round((a-b)/(c-d)/2,3)
    a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1)
    b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1)
    c = (x2 - x1)*(y3 - y1)
    d = (x3 - x1)*(y2 - y1)
    px = round((a-b)/(c-d)/2,3)
    print('%s %s %s' %(px, py, r))

Submission status: Wrong Answer

Solution code:
import sys
import math
n = int(sys.stdin.readline().rstrip())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float, sys.stdin.readline().rstrip().split(' '))
    p = ((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2-x2**2+y1**2-y2**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
    r = math.sqrt((p-x1)**2 + (p-y1)**2)
    print("{:0.3f} {:0.3f} {:0.3f}".format(round(p,3),round(q,3),round(r,3)))

Submission status: Wrong Answer

Solution code:
def main():
	import math
	n = int(input())
	w = [0]*6

	for _ in range(n):
		x1, y1, x2, y2, x3, y3 = map(float, input().split())
		w[0] = 2*(x2-x1)
		w[1] = 2*(y2-y1)
		w[2] = x2**2 + y2**2 - x1**2 - y1**2
		w[3] = 2*(x3-x1)
		w[4] = 2*(y3-y1)
		w[5] = x3**2 + y3**2 - x1**2 - y1**2

		x, y = solve(w)

		r = math.sqrt((x-x1)**2 + (y-y1)**2)

		print(x, y, "{:.3f}".format(r))


def solve(w):
	x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
	y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
	x = round(x, 3)
	y = round(y, 3)
	if x == -0.0:
	    x = 0.0
	if y == -0.0:
	    y = 0.0
	return x, y


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	import math
	n = int(input())
	w = [0]*6

	for _ in range(n):
		x1, y1, x2, y2, x3, y3 = map(float, input().split())
		w[0] = 2*(x2-x1)
		w[1] = 2*(y2-y1)
		w[2] = x2**2 + y2**2 - x1**2 - y1**2
		w[3] = 2*(x3-x1)
		w[4] = 2*(y3-y1)
		w[5] = x3**2 + y3**2 - x1**2 - y1**2

		x, y = solve(w)

		r = math.sqrt((x-x1)**2 + (y-y1)**2)

		print("{:.3f} {:.3f} {:.3f}".format(x, y, r))


def solve(w):
	x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
	y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
	x = round(x, 3)
	y = round(y, 3)
	if x == -0.0:
	    x = 0.0
	if y == -0.0:
	    y = 0.0
	return x, y


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def main():
	import math
	n = int(input())
	w = [0]*6

	for _ in range(n):
		x1, y1, x2, y2, x3, y3 = map(float, input().split())
		w[0] = 2*(x2-x1)
		w[1] = 2*(y2-y1)
		w[2] = x1**2 + y1**2 - x2**2 - y2**2
		w[3] = 2*(x3-x1)
		w[4] = 2*(y3-y1)
		w[5] = x1**2 + y1**2 - x3**2 - y3**2

		x, y = solve(w)

		r = math.hypot((x-x1), (y-y1))

		print("{:.3f} {:.3f} {:.3f}".format(x, y, r))


def solve(w):
	x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
	y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
	x = round(x, 3)
	y = round(y, 3)
	if x == -0.0:
	    x = 0.0
	if y == -0.0:
	    y = 0.0
	return x, y


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import math

n = int(raw_input())

for i in range(n):
	data = map(float, raw_input().split())
	x1 = data[0]
	y1 = data[1]
	x2 = data[2]
	y2 = data[3]
	x3 = data[4]
	y3 = data[5]

	k = 0.5 * ( (x3-x2)*(x3-x1) + (y3-y2)*(y3-y1) ) / ( (x2-x1)*(y3-y1) + (y2-y1)*(x3-x1) )

	x = 0.5 * (x1 + x2) - k * (y2 - y1)
	y = 0.5 * (y1 + y2) + k * (x2 - x1)

	r = math.sqrt( (x-x1)**2 + (y-y1)**2 )

	print("{:.3f} {:.3f} {:.3f}".format(x,y,r))

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
i = 0
while (i < n):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
    m1,m2=(x1+x2) / 2, (y1+y2) / 2
    n1,n2=(x1+x3) / 2, (y1+y3) / 2

    if y1==y2:
        a = 1
        b = 0
        c = m1
    elif x1==x2:
        a = 0
        b = 1
        c = m2
    else:
        a = (x2-x1) / (y2-y1)
        b = 1
        c = m2+a*m1

    if y1==y3:
        d = 1
        e = 0
        f = n1
    elif x1==x3:
        d = 0
        e = 1
        f = n2
    else:
        d = (x3-x1) / (y3-y1)
        e = 1
        f = n2+a*n1

    if a*d-b*c==0:
        print "not exist answer"
    else:
        x = (float((c*e-b*f)) / (a*e-b*d))+0
        y = (float((a*f-c*d)) / (a*e-b*d))+0
        print ('%.3f' % round(x,3)), ('%.3f' % round(y,3)),
        print ('%.3f' % round(((((x - x1)**2+(y-y1)**2)**0.5)),3))
        i += 1

Submission status: Wrong Answer

Solution code:
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=((a*a+b*b)*(c-d)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print(f"{x:.4} {y:.4} {(x*x+y*y)**.5:.4}")

Submission status: Wrong Answer

Solution code:
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print(f"{x:.4} {y:.4} {(x*x+y*y)**.5:.4}")

Submission status: Wrong Answer

Solution code:
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print(f"{x:.3f} {y:.3f} {(x*x+y*y)**.5:.3f}")

Submission status: Wrong Answer

Solution code:
import math

def length(ax, ay, bx, by):
    return math.sqrt((ax - bx)**2 + (ay - by)**2)

n = int(input())
for i in range(n):
    ax, ay, bx, by, cx, cy = map(float, input().split())
    ab = length(ax, ay, bx, by)
    bc = length(bx, by, cx, cy)
    ca = length(cx, cy, ax, ay)
    s = (ab + bc + ca) / 2.0
    area = math.sqrt(s * (s - ab) * (s - bc) * (s - ca))
    sinA = area * 2.0 / bc
    angleB = math.asin(sinA / ab)
    angleC = math.asin(sinA / ca)
    angleA = math.pi - angleB - angleC
    sin2A = math.sin(2.0 * angleA)
    sin2B = math.sin(2.0 * angleB)
    sin2C = math.sin(2.0 * angleC)
# 外心の計算
    center_x = (ax * sin2A + bx * sin2B + cx * sin2C) / (sin2A + sin2B + sin2C)
    center_y = (ay * sin2A + by * sin2B + cy * sin2C) / (sin2A + sin2B + sin2C)
# 半径の計算
    radius = bc / math.sin(angleA) / 2.0
    print("{0:.3f} {1:.3f} {2:.3f}".format(center_x, center_y, radius))

Submission status: Wrong Answer

Solution code:
from math import hypot
n=int(input())
for i in range(n):
	x1,y1,x2,y2,x3,y3=map(float,input().split())
	x4=((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
	y4=((x1-x3)*(x1**2-x2**2+y1**2-x1**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
	r=hypot(x1-x4,y1-y4)
	print("{:.3f} {:.3f} {:.3f}".format(x4,y4,r))

Submission status: Wrong Answer

Solution code:
import math
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))
    r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)
    print("{:.4f} {:.4f} {:.4f}".format(p, q, r))

Submission status: Wrong Answer

Solution code:
import math
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))
    r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)
    p = abs(p) if abs(p) < 10e-5 else p
    q = abs(q) if abs(q) < 10e-5 else q
    print("{:.4f} {:.4f} {:.4f}".format(p, q, r))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt
# import numpy as np


n = int(input())

for i in range(n):
    tmp = input().split(' ')
    
    a, b, c = [(float(tmp[i]), float(tmp[i+1])) for i in range(0, len(tmp), 2)]
    
    #A = np.array(((a[0], a[1], 1),
    #              (b[0], b[1], 1),
    #              (c[0], c[1], 1)))
    A_tmp1 = 1/(a[0]*b[1] + a[1]*c[0] + b[0]*c[1] - b[1]*c[0] - a[1]*b[0] - a[0]*c[1])
    A_tmp2 = [[b[1]-c[1], -(a[1]-c[1]), a[1]-b[1]],
              [-(b[0]-c[0]),  (a[0]-c[0]), -(a[0]-b[0])],
              [b[0]*c[1] - b[1]*c[0], -(a[0]*c[1] - a[1]*c[0]), a[0]*b[1] - a[1]*b[0]]]
    A = [list(map(lambda x: A_tmp1*x, A_tmp2[i])) for i in range(3)]
    
    #B = np.array((((-(a[0]**2 + a[1]**2))),
    #              ((-(b[0]**2 + b[1]**2))),
    #              ((-(c[0]**2 + c[1]**2)))))
    B = [[-(a[0]**2 + a[1]**2)],
         [-(b[0]**2 + b[1]**2)],
         [-(c[0]**2 + c[1]**2)]]
    
    
    tmp = [sum([A[i][j]*B[j][0] for j in range(3)]) for i in range(3)]
    # tmp = np.dot(np.linalg.inv(A), B)
    print(tmp)
    
    x = -tmp[0]/2
    y = -tmp[1]/2
    r = sqrt((tmp[0]**2 + tmp[1]**2 - 4*tmp[2])/4)
    
    print('{:.3} {:.3} {:.3}'.format(x, y, r))

Submission status: Wrong Answer

Solution code:
from math import sqrt
def f(x):
    a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
    b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
    l = 0.5 * b / a
    X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
    Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
    R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
    print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
n = int(input())
a = []
for _ in range(n):
        a.append(list((map(float, input().split()))))
for i in a:
    f(i)

Submission status: Wrong Answer

Solution code:
from math import sqrt
def g(x):
    y = (((1000 * x) * 2 + 1) // 2) / 1000
    return y
def f(x):
    a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
    b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
    l = 0.5 * b / a
    X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
    Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
    R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
    X = g(X)
    Y = g(Y)
    R = g(R)
    print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
n = int(input())
a = []
for _ in range(n):
    a.append(list((map(float, input().split()))))
for i in a:
    f(i)

Submission status: Wrong Answer

Solution code:
from math import *
def g(x):
    y = (((1000 * abs(x)) * 2 + 1) // 2) / 1000
    if x < 0:
        y *= -1
    return y
def f(x):
    a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
    b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
    l = 0.5 * b / a
    X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
    Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
    R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
    X = g(X)
    Y = g(Y)
    R = g(R)
    print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
n = int(input())
a = []
for _ in range(n):
    a.append(list((map(float, input().split()))))
for i in a:
    f(i)

Submission status: Wrong Answer

Solution code:
from math import *
def g(x):
    y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
    if x < 0:
        y *= -1
    return y
def f(x):
    a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
    b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
    l = 0.5 * b / a
    X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
    Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
    R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
    X = g(X)
    Y = g(Y)
    R = g(R)
    print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
n = int(input())
a = []
for _ in range(n):
    a.append(list((map(float, input().split()))))
for i in a:
    f(i)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from math import *
def g(x):
	y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
	if x < 0:
		y *= -1
	return y
def f(x):
	a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
	b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
	l = 0.5 * b / a
	X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
	Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
	R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
	X = "{0:.3f}".format(g(X))
	Y = "{0:.3f}".format(g(Y))
	R = "{0:.3f}".format(g(R))
	if X == "-0.000" or Y == "-0.000" or R == "-0.000":
		while True:
			X += 0
	print(X + " " + Y + " " + R)
n = int(input())
a = []
for _ in range(n):
	a.append(list((map(float, input().split()))))
for i in a:
	f(i)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from math import *
def g(x):
	y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
	return y / abs(y) * y
def func(x):
	x1, y1, x2, y2, x3, y3 = x

	vx1 = x2 - x1
	vy1 = y2 - y1
	vx2 = x3 - x1
	vy2 = y3 - y1
	k = (vx2 ** 2 + vy2 ** 2 - vx1 * vx2 - vy1 * vy2) / (vy1 * vx2 - vx1 * vy2) / 2
	x = vx1 / 2 + k * vy1 + x1
	y = vy1 / 2 - k * vx1 + y1
	r = sqrt((x1 - x) ** 2 + (y1 - y) ** 2)
	print("{0:.3f} {1:.3f} {2:.3f}".format(g(x), g(y), g(r)))
n = int(input())
for _ in range(n):
	func(list(map(float, input().split())))

Submission status: Wrong Answer

Solution code:
import math

def calc(x, y):
    s = math.fabs((x[1]-x[0])*(y[2]-y[0]) - (x[2]-x[0])*(y[1]-y[0]))/2
    a = ((x[2]-x[1])**2 + (y[2]-y[1])**2)**0.5
    b = ((x[0]-x[2])**2 + (y[0]-y[2])**2)**0.5
    c = ((x[1]-x[0])**2 + (y[1]-y[0])**2)**0.5
    r = a*b*c/(4*s)

    a = [2*(x[1]-x[0]), 2*(x[2]-x[0])]
    b = [2*(y[1]-y[0]), 2*(y[2]-y[0])]
    c = [x[0]**2 - x[1]**2 + y[0]**2 -y[1]**2, x[0]**2 - x[2]**2 + y[0]**2 -y[2]**2]
    x = (b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0])
    y = (c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0])
    
    return [(x*10000+5)/10000, (y*10000+5)/10000, (r*10000+5)/10000]
    #return [x,y,r]

for i in range(int(input())):
    list = [float(l) for l in raw_input().split()]
    x,y = [list[0::2],list[1::2]]

    ans = calc(x,y)

    print "%.3f %.3f %.3f" % (ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
#coding: utf-8
def solve(a, b, c, d, e, f):
    agn = a*e - b*d
    x = (e*c - b*f)/float(agn)
    y = (-d*c + a*f)/float(agn)
    if x == 0.: x = 0.
    if y == 0.: y = 0.
    return (x, y)
   
while 1:
    try:
        n = input()
        for i in xrange(n):
            x = [0 for i in xrange(3)]
            y = [0 for i in xrange(3)]
            a,b,t = [[0 for i in xrange(2)] for i in xrange(3)]
            p,q,s = [[0 for i in xrange(2)] for i in xrange(3)]
            x[0],y[0],x[1],y[1],x[2],y[2] = map(float, raw_input().split())
            for j in xrange(2):
                a[j] = (x[j+1] - x[j])/2
                b[j] = (y[j+1] - y[j])/2
                if x[j+1] - x[j] == 0.:
                    p[j] = 0.
                    q[j] = -1.
                    s[j] = -b[j]
                elif y[j+1] - y[j] == 0.:
                    p[j] = -1.
                    q[j] = -0
                    s[j] = -a[j]
                else:
                    t[j] = (y[j+1] - y[j]) / (x[j+1] - x[j])
                    p[j] = -1./t[j]
                    q[j] = -1.
                    s[j] = -(a[j]/t[j])-b[j]
            c = solve(p[0], q[0], s[0], p[1], q[1], s[1])
            r = ((x[0]-c[0])**2 + (y[0]-c[1])**2)**0.5
            print "%.3f %.3f %.3f" % (c[0], c[1], r)
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
def heron(a,b,c):
    s = 0.5*(a+b+c)
    return (s*(s-a)*(s-b)*(s-c))**0.5

n = input()

for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float, raw_input().split(' '))
    l1 = ((x2-x3)**2+(y2-y3)**2)**0.5
    l2 = ((x3-x1)**2+(y3-y1)**2)**0.5
    l3 = ((x1-x2)**2+(y1-y2)**2)**0.5
    S = heron(l1,l2,l3)
    px = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
          (l3**2 + l1**2 - l2**2)*l2*x2**2 +\
          (l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
    py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
          (l3**2 + l1**2 - l2**2)*l2*y2**2 +\
          (l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
    r = ((px-x1)**2+(py-y1)**2)**0.5
    print px,py,r

Submission status: Wrong Answer

Solution code:
def heron(a,b,c):
    s = 0.5*(a+b+c)
    return (s*(s-a)*(s-b)*(s-c))**0.5

n = input()
ans = []
while True:
    try:
        for i in range(n):
            x1,y1,x2,y2,x3,y3 = map(float, raw_input().split(' '))
            l1 = ((x2-x3)**2+(y2-y3)**2)**0.5
            l2 = ((x3-x1)**2+(y3-y1)**2)**0.5
            l3 = ((x1-x2)**2+(y1-y2)**2)**0.5
            S = heron(l1,l2,l3)
            px = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
                  (l3**2 + l1**2 - l2**2)*l2*x2**2 +\
                  (l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
            py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
                  (l3**2 + l1**2 - l2**2)*l2*y2**2 +\
                  (l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
            r = ((px-x1)**2+(py-y1)**2)**0.5
            ans.append([px,py,r])
        for an in ans:
            print an[0],an[1],an[2]
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
def heron(a,b,c):
    s = 0.5*(a+b+c)
    return (s*(s-a)*(s-b)*(s-c))**0.5

n = input()
ans = []
while True:
    try:
        for i in range(n):
            x1,y1,x2,y2,x3,y3 = map(float, raw_input().split(' '))
            l1 = ((x2-x3)**2+(y2-y3)**2)**0.5
            l2 = ((x3-x1)**2+(y3-y1)**2)**0.5
            l3 = ((x1-x2)**2+(y1-y2)**2)**0.5
            S = heron(l1,l2,l3)
            px = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
                  (l3**2 + l1**2 - l2**2)*l2*x2**2 +\
                  (l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
            py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
                  (l3**2 + l1**2 - l2**2)*l2*y2**2 +\
                  (l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
            r = ((px-x1)**2+(py-y1)**2)**0.5
            ans.append([px,py,r])
        for an in ans:
            print '%.3f %.3f %.3f ' % (an[0],an[1],an[2])
    except EOFError:
        break