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:
import math

def run():
    n = int(input())
    epsilon = 1e-16
    for _ in range(n):
        x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
        u1 = (x1-x3)*(x2-x1)*(x3-x2)
        u2 = (x2-x1)*(y3-y2)*(y3+y2)
        u3 = (x3-x2)*(y2-y1)*(y2+y1)
        v = x1*x2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 + x3*y2
        Py = (-u1 + u2 - u3) / (v + epsilon) / 2
        Px = (x2**2 - x1**2 + y2**2 - y1**2 - (y2 - y1)*Py) / ((x2-x1) + epsilon) / 2
        r = math.sqrt((Px-x1)**2 + (Py-y1)**2)
        print('{0:.3f} {1:.3f} {2:.3f}'.format(round(Px,3), round(Py,3), round(r,3)))

if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
import math

def run():
    n = int(input())
    epsilon = 1e-16
    for _ in range(n):
        x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
        u1 = (x1-x3)*(x2-x1)*(x3-x2)
        u2 = (x2-x1)*(y3-y2)*(y3+y2)
        u3 = (x3-x2)*(y2-y1)*(y2+y1)
        v = x1*x2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 + x3*y2
        Py = (-u1 + u2 - u3) / v / 2
        Px = (x2**2 - x1**2 + y2**2 - y1**2 - (y2 - y1)*Py) / (x2-x1 + epsilon) / 2
        r = math.sqrt((Px-x1)**2 + (Py-y1)**2)
        print('{0:.3f} {1:.3f} {2:.3f}'.format(round(Px,3), round(Py,3), round(r,3)))

if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
import math

def run():
    n = int(input())
    epsilon = 1e-20
    for _ in range(n):
        x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
        u1 = (x1-x3)*(x2-x1)*(x3-x2)
        u2 = (x2-x1)*(y3-y2)*(y3+y2)
        u3 = (x3-x2)*(y2-y1)*(y2+y1)
        v = x1*x2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 + x3*y2
        Py = (-u1 + u2 - u3) / v / 2
        Px = (x2**2 - x1**2 + y2**2 - y1**2 - (y2 - y1)*Py) / (x2-x1 + epsilon) / 2
        r = math.sqrt((Px-x1)**2 + (Py-y1)**2)
        print('{0:.3f} {1:.3f} {2:.3f}'.format(round(Px,3), round(Py,3), round(r,3)))

if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
import math

def run():
    n = int(input())
    epsilon = 1e-40
    for _ in range(n):
        x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
        u1 = (x1-x3)*(x2-x1)*(x3-x2)
        u2 = (x2-x1)*(y3-y2)*(y3+y2)
        u3 = (x3-x2)*(y2-y1)*(y2+y1)
        v = x1*x2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 + x3*y2
        Py = (-u1 + u2 - u3) / v / 2
        Px = (x2**2 - x1**2 + y2**2 - y1**2 - (y2 - y1)*Py) / (x2-x1 + epsilon) / 2
        r = math.sqrt((Px-x1)**2 + (Py-y1)**2)
        print('{0:.3f} {1:.3f} {2:.3f}'.format(round(Px,3), round(Py,3), round(r,3)))

if __name__ == '__main__':
    run()

Submission status: Wrong Answer

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

import cmath

class Point(object):
    def __init__(self, x, y):
        self.point = complex(x, y)
    def __str__(self):
        return "x = {0}, y = {1}".format(self.point.real, self.point.imag)

class Triangle(Point):
    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c
        # ３辺の長さ
        self.edgeA = abs(b.point-c.point)
        self.edgeB = abs(c.point-a.point)
        self.edgeC = abs(a.point-b.point)
        # ３角の大きさ
        self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
        self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
        self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)

    # 角度を求める
    def angle(A, B, C):
        return cmath.acos( (B*B+C*C-A*A)/(2*B*C) )


    # 外接円の半径
    def circumscribedCircleRadius(self):
        return abs((self.edgeA/cmath.sin(self.angleA))/2)

    # 外心
    def circumscribedCircleCenter(self):
        A = cmath.sin(2*self.angleA)
        B = cmath.sin(2*self.angleB)
        C = cmath.sin(2*self.angleC)
        X = (self.a.point.real*A + self.b.point.real*B + self.c.point.real*C) / (A+B+C)
        Y = (self.a.point.imag*A + self.b.point.imag*B + self.c.point.imag*C) / (A+B+C)
        return complex(X, Y)

n = int(input())
for i in range(n):
    line = list(map(float, input().split()))
    p1 = Point(line[0], line[1])
    p2 = Point(line[2], line[3])
    p3 = Point(line[4], line[5])
    T = Triangle(p1, p2, p3)
    center = T.circumscribedCircleCenter()
    print("{0:.4f} {1:.4f} {2:.4f}".format(center.real, center.imag, T.circumscribedCircleRadius()))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def calc_det(lis):
  return lis[0]*lis[3]-lis[1]*lis[2]

def sq(x):
  return x*x

for s in sys.stdin:
  d = map(float, s.split() )
  if len(d) == 1:
    continue
  x1,y1,x2,y2,x3,y3 = d[0],d[1],d[2],d[3],d[4],d[5]
  d11 = 2*(x3-x2)
  d12 = 2*(y3-y2)
  d21 = 2*(x2-x1)
  d22 = 2*(y2-y1)
  x11 = sq(x3)-sq(x2)+sq(y3)-sq(y2)
  x21 = sq(x2)-sq(x1)+sq(y2)-sq(y1)
  y12 = x11
  y22 = x21

  x0 = calc_det( [x11,d12,x21,d22] )/calc_det( [d11,d12,d21,d22] )
  y0 = calc_det( [d11,y12,d21,y22] )/calc_det( [d11,d12,d21,d22] )

  r = ( (x0-x1)**2 + (y0-y1)**2 )**0.5

print "%.3f %.3f %.3f" % (x0,y0,r)

'''
Bibliography
３点を通る円の半径を求む（#７）
http://www.geocities.jp/jtqsw192/FIG/313r/3point_r.htm
'''

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
# main.py

n = map(int,raw_input().split())
for i in xrange(0,n[0]):
	x1,x2,x3,y1,y2,y3 = map(float,raw_input().split())
	print x1

Submission status: Wrong Answer

Solution code:
import sys
f = sys.stdin

def take2(iterable):
    while True:
        yield next(iterable), next(iterable)
#外積
def cross(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real
# 線分13と線分24の交点を求める
def get_intersection(p1,p2,p3,p4):
    a1 = p4 - p2
    b1 = p2 - p3
    b2 = p1 - p2
    s1 = cross(a1, b2) / 2
    s2 = cross(a1, b1) / 2
    print(s1,s2)
    return p1 + (p3 - p1) * s1 / (s1 + s2)

n = int(f.readline())
for i in range(n):
    p1, p2, p3 = [x + y * 1j for x, y in take2(map(float, f.readline().split()))]
    p12 = (p1 + p2) / 2
    p13 = (p1 + p3) / 2
    pxy = get_intersection(p12,p13,p12 + (p2 - p1) * 1j,p13 + (p1 - p3) * 1j)
    r = abs(pxy - p1)
    print('{:.3f} {:.3f} {:.3f}'.format(pxy.real,pxy.imag,r))

Submission status: Wrong Answer

Solution code:
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2.0
            a,b,c,d,e,f=1.0,0.0,(x1+x2)/2.0,-a2,1.0,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2.0
            a,b,c,d,e,f=-a1,1.0,b1,1.0,0.0,(x1+x3)/2.0
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2.0
        b2=((y3+y1)-a2*(x1+x3))/2.0
        a,b,c,d,e,f=-a1,1.0,b1,-a2,1.0,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

Submission status: Wrong Answer

Solution code:
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2-y1 == 0. or y3-y1 == 0.:
        if y2-y1 == 0.:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2.0
            a,b,c,d,e,f=1.0,0.0,(x1+x2)/2.0,-a2,1.0,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2.0
            a,b,c,d,e,f=-a1,1.0,b1,1.0,0.0,(x1+x3)/2.0
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2.0
        b2=((y3+y1)-a2*(x1+x3))/2.0
        a,b,c,d,e,f=-a1,1.0,b1,-a2,1.0,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

Submission status: Wrong Answer

Solution code:
def calc(l):
	A1=2*(l[1][0]-l[0][0])
	B1=2*(l[1][1]-l[0][1])
	C1=l[0][0]**2-l[1][0]**2+l[0][1]**2-l[1][1]**2
	A2=2*(l[2][0]-l[0][0])
	B2=2*(l[2][1]-l[0][1])
	C2=l[0][0]**2-l[2][0]**2+l[0][1]**2-l[2][1]**2
	X=round((B1*C2-B2*C1)/(A1*B2-A2*B1),3)
	Y=round((C1*A2-C2*A1)/(A1*B2-A2*B1),3)
	return X,Y
l=[zip(*[iter(map(float,raw_input().split()))]*2) for i in range(input())]
for ll in l:
	print "%.3f %.3f"%(calc(ll))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

n = int(raw_input())
data = [0 for _ in range(n)]
for i in range(n):
    data[i] = map(float,raw_input().split(' '))
for (x1,y1,x2,y2,x3,y3) in data:
    det = 4*x2*y3 - 4*y2*x3
    if det != 0:
        px = ((x2**2 + y2**2)*2*y3 - (x3**2 + y3**2)*2*y2)/det
        if px == 0:
            px = 0.
        py = (2*x2*(x3**2 + y3**2) - 2*x3*(x2**2 + y2**2))/det
        if py == 0:
            py = 0.
        r = ((px-x1)**2 + (py-y1)**2)**.5
        print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)
    else:
        print '0.000 0.000 0.000'

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = 4*x2*y3 - 4*y2*x3
    if det != 0:
        px = ((x2**2 + y2**2)*2*y3 - (x3**2 + y3**2)*2*y2)/det
        if px == 0:
            px = 0.
        py = (2*x2*(x3**2 + y3**2) - 2*x3*(x2**2 + y2**2))/det
        if py == 0:
            py = 0.
        r = ((px-x1)**2 + (py-y1)**2)**.5
        print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)
    else:
        print '0.000 0.000 0.000'

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def __det(matrix):
    return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]

def __sqdist(p1,p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = __det([[(x1-x2),(y1-y2)],[(x1-x3),(y1-y3)]])
    c1 = (x1**2-x2**2+y1**2-y2**2)/2
    c2 = (x1**2-x3**2+y1**2-y3**2)/2
    px = __det([[c1,(y1-y2)],[c2,(y1-y3)]])/det
    py = __det([[(x1-x2),c1],[(x1-x3),c2]])/det
    r = __sqdist([x1,x2],[px,py])
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def __det(matrix):
    return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]

def __sqdist(p1,p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = __det([[(x1-x2),(y1-y2)],[(x1-x3),(y1-y3)]])
    c1 = (x1**2-x2**2+y1**2-y2**2)/2
    c2 = (x1**2-x3**2+y1**2-y3**2)/2
    if det != 0:
        px = __det([[c1,(y1-y2)],[c2,(y1-y3)]])/det
        py = __det([[(x1-x2),c1],[(x1-x3),c2]])/det
    else:
        px,py = 0.,0.
    r = __sqdist([x1,x2],[px,py])
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def __det(matrix):
    return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]

def __sqdist(p1,p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = __det([[(x1-x2),(y1-y2)],[(x1-x3),(y1-y3)]])
    c1 = (x1**2-x2**2+y1**2-y2**2)/2
    c2 = (x1**2-x3**2+y1**2-y3**2)/2
    if det != 0:
        px = __det([[c1,(y1-y2)],[c2,(y1-y3)]])/det
        py = __det([[(x1-x2),c1],[(x1-x3),c2]])/det
    elif x1==x2==x3 and y1==y2==y3:
        px,py = x1,y1
    else:
        if x1==x2:
            px = (x1+x3)/2
            py = (y1+y3)/2
        elif x1==x3:
            px = (x1+x2)/2
            py = (y1+y2)/2
        else:
            px = (x2+x3)/2
            py = (y2+y3)/2
    r = __sqdist([x1,x2],[px,py])
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def __det(matrix):
    return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]

def __sqdist(p1,p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = __det([[(x2-x1),(y2-y1)],[(x3-x1),(y3-y1)]])
    c1 = (x2**2-x1**2+y2**2-y1**2)/2
    c2 = (x3**2-x1**2+y3**2-y1**2)/2
    px = __det([[c1,(y1-y2)],[c2,(y1-y3)]])/det
    py = __det([[(x1-x2),c1],[(x1-x3),c2]])/det
    r = __sqdist([x1,x2],[px,py])
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def __det(matrix):
    return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]

def __sqdist(p1,p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = __det([[(x2-x1),(y2-y1)],[(x3-x1),(y3-y1)]])
    c1 = (x1**2-x2**2+y1**2-y2**2)/2
    c2 = (x1**2-x3**2+y1**2-y3**2)/2
    px = __det([[c1,(y1-y2)],[c2,(y1-y3)]])/det
    py = __det([[(x1-x2),c1],[(x1-x3),c2]])/det
    r = __sqdist([x1,x2],[px,py])
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Submission status: Wrong Answer

Solution code:
def main():
    import math
    while True:
        try:
            for i in range(int(input())):
                x1,y1,x2,y2,x3,y3=map(float,input().split())

                a=y1-y2
                b=y1-y3

                if a==0:
                    x=(x1+x2)/2
                    c=(x3-x1)/(y1-y3)
                    d=(-x1-x3)/2+(y1+y3)/2
                    y=c*x+d

                elif b==0:
                    x=(x1+x3)/2
                    c=(x2-x1)/(y1-y2)
                    d=(-x1-x3)/2+(y1+y3)/2
                    y=c*x+d

                else:
                    a=(x2-x1)/(y1-y2)
                    b=(-x1-x2)/2+(y1+y2)/2
                    c=(x3-x1)/(y1-y3)
                    d=(-x1-x3)/2+(y1+y3)/2

                    x=(d-b)/(a-c)
                    y=a*x+b

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import math
    for i in range(int(input())):
        x1,y1,x2,y2,x3,y3=map(float,input().split())

        a=y1-y2
        b=y1-y3

        if a==0:
            x=(x1+x2)/2
            c=(x3-x1)/(y1-y3)
            d=(-x1-x3)/2+(y1+y3)/2
            y=c*x+d

        elif b==0:
            x=(x1+x3)/2
            c=(x2-x1)/(y1-y2)
            d=(-x1-x3)/2+(y1+y3)/2
            y=c*x+d

        else:
            a=(x2-x1)/(y1-y2)
            b=(-x1-x2)/2+(y1+y2)/2
            c=(x3-x1)/(y1-y3)
            d=(-x1-x3)/2+(y1+y3)/2

            x=(d-b)/(a-c)
            y=a*x+b

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import math
    for i in range(int(input())):
        x1,y1,x2,y2,x3,y3=map(float,input().split())

        a=y1-y2
        b=y1-y3

        if a==0:
            x=(x1+x2)/2
            c=(x3-x1)/(y1-y3)
            d=(-x1-x3)/2+(y1+y3)/2
            y=c*x+d

        elif b==0:
            x=(x1+x3)/2
            c=(x2-x1)/(y1-y2)
            d=(-x1-x2)/2+(y1+y2)/2
            y=c*x+d

        else:
            a=(x2-x1)/(y1-y2)
            b=(-x1-x2)/2+(y1+y2)/2
            c=(x3-x1)/(y1-y3)
            d=(-x1-x3)/2+(y1+y3)/2

            x=(d-b)/(a-c)
            y=a*x+b

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import math
    for i in range(int(input())):
        x1,y1,x2,y2,x3,y3=map(float,input().split())

        a=y1-y2
        b=y1-y3

        if a==0:
            x=(x1+x2)/2
            c=(x3-x1)/(y1-y3)
            d=(-x1-x3)/2+(y1+y3)/2
            y=c*x+d

        elif b==0:
            x=(x1+x3)/2
            c=(x2-x1)/(y1-y2)
            d=(-x1-x2)/2+(y1+y2)/2
            y=c*x+d

        else:
            a=(x2-x1)/(y1-y2)
            b=(-x1-x2)/2+(y1+y2)/2
            c=(x3-x1)/(y1-y3)
            d=(-x1-x3)/2+(y1+y3)/2

            x=(d-b)/(a-c)
            y=a*x+b

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import math
    for i in range(int(input())):
        x1,y1,x2,y2,x3,y3=map(float,input().split())

        a=y1-y2
        b=y1-y3

        if a==0:
            x=(x1+x2)/2
            c=(x3-x1)/(y1-y3)
            d=c*(-x1-x3)/2+(y1+y3)/2
            y=c*x+d

        elif b==0:
            x=(x1+x3)/2
            c=(x2-x1)/(y1-y2)
            d=c*(-x1-x2)/2+(y1+y2)/2
            y=c*x+d

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

            x=(d-b)/(a-c)
            y=a*x+b

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

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

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    a1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
    a2 = y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2
    px = ((y1 - y3) * a1 - (y1 - y2) * a2) / \
        (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3))
    py = ((x1 - x3) * a1 - (x1 - x2) * a2) / \
        (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3))
    r = math.sqrt(px ** 2 + py ** 2)
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    a1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
    a2 = y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2
    px = ((y1 - y3) * a1 - (y1 - y2) * a2) / (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3))
    py = ((x1 - x3) * a1 - (x1 - x2) * a2) / (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3))
    r = math.sqrt(px ** 2 + py ** 2)
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
i = 0
while i < n:
   x1, y1, x2, y2, x3, y3 = map(float,input().split())
   a = x2 - x1
   b = y2 - y1
   c = x3 - x1
   d = y3 - y1
   e = a * (x1 + x2) + b * (y1 + y3)
   f = c * (x1 + x2) + d * (y1 + y3)
   g = 2.0 * (a * (y3 - y2) - b * (x3 - x2))
   if g == 0:
       exit()
   px = (d * e - b * f) / g
   py = (a * f - c * e) / g
   radius = ( (py - y1)*(py - y1) + (px - x1)*(px - x1) )
   print("%.3f %.3f %.3f"%(px,py,math.sqrt(radius)))
   i=i+1

Submission status: Wrong Answer

Solution code:
#! -*- coding:utf-8 -*-
import math
n = input()
for x in xrange(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
    a1 = 2.0*(x2-x1)
    b1 = 2.0*(y2-y1)
    x12 = x1**2
    y12 = y1**2
    c1 = x12-x2**2+y12+y2**2
    a2 = 2.0*(x3-x1)
    b2 = 2.0*(y3-y1)
    c2 = x12-x3**2+y12-y3**2
    denom=(a1*b2-a2*b1)
    x = (b1*c2-b2*c1)/denom
    y = (c1*a2-c2*a1)/denom
    r = math.sqrt((x-x1)**2+(y-y1)**2)

    print "%.3f %.3f %.3f"%(x,y,r)

Submission status: Wrong Answer

Solution code:
#! -*- coding:utf-8 -*-
import math
n = input()
for x in xrange(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
    a1 = 2.0*(x2-x1)
    b1 = 2.0*(y2-y1)
    x12 = x1**2
    y12 = y1**2
    c1 = x12-x2**2+y12+y2**2
    a2 = 2.0*(x3-x1)
    b2 = 2.0*(y3-y1)
    c2 = x12-x3**2+y12-y3**2
    denom=(a1*b2-a2*b1)
    # print "x1^2 : "+str(x12)
    # print "y1^2 : "+str(y12)
    # print "a1 : "+str(a1)
    # print "b1 : "+str(b1)
    # print "c1 : "+str(c1)
    # print "a2 : "+str(a2)
    # print "b2 : "+str(b2)
    # print "c2 : "+str(c2)
    # print "denom : "+str(denom)
    x = (b1*c2-b2*c1)/denom
    y = (c1*a2-c2*a1)/denom
    r = math.sqrt((x-x1)**2+(y-y1)**2)

    print "%.3f %.3f %.3f"%(x,y,r)

Submission status: Wrong Answer

Solution code:
#encoding=utf-8
import math

x = input()
x1,y1,x2,y2,x3,y3 = map(float, raw_input().split())

p = ((y1 - y3)*(y1**2 - y1**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))

print ("{0:.3f}".format(round(p, 3))),("{0:.3f}".format(round(q, 3))),round(math.sqrt((x1-p)**2 + (y1-q)**2),3)

Submission status: Wrong Answer

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

import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def calcCenter(p1, p2, p3):
    p = ((p1.y-p2.y)*(p3.x*p3.x-p1.y*p2.y)+(p2.y-p2.y)*(p1.x*p1.x-p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x-p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
    q = ((p1.x-p2.x)*(p3.y*p3.y-p1.x*p2.x)+(p2.x-p2.x)*(p1.y*p1.y-p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y-p3.x*p1.x)) / ((-2)*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
    return Point_Class(p, q)

def calcRadius(p, pc):
    return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pc = calcCenter(p1, p2, p3)
    r = calcRadius(p1, pc)
    print "%f %f %f" %(pc.x, pc.y, r)

Submission status: Wrong Answer

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

import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def calcCenter(p1, p2, p3):
    p = ((p1.y-p2.y)*(p3.x*p3.x+p1.y*p2.y)+(p2.y-p2.y)*(p1.x*p1.x+p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x+p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
    q = ((p1.x-p2.x)*(p3.y*p3.y-p1.x*p2.x)+(p2.x-p2.x)*(p1.y*p1.y-p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y-p3.x*p1.x)) / ((-2)*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
    return Point_Class(p, q)

def calcRadius(p, pc):
    return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pc = calcCenter(p1, p2, p3)
    r = calcRadius(p1, pc)
    print "%f %f %f" %(pc.x, pc.y, r)

Submission status: Wrong Answer

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

import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def calcCenter(p1, p2, p3):
    p = ((p1.y-p2.y)*(p3.x*p3.x+p1.y*p2.y)+(p2.y-p2.y)*(p1.x*p1.x+p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x+p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
    q = ((p1.x-p2.x)*(p3.y*p3.y+p1.x*p2.x)+(p2.x-p2.x)*(p1.y*p1.y+p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y+p3.x*p1.x)) / (2*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
    return Point_Class(p, q)

def calcRadius(p, pc):
    return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pc = calcCenter(p1, p2, p3)
    r = calcRadius(p1, pc)
    print "%f %f %f" %(pc.x, pc.y, r)

Submission status: Wrong Answer

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

import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def calcCenter(p1, p2, p3):
    p = ((p1.y-p2.y)*(p3.x*p3.x+p1.y*p2.y)+(p2.y-p3.y)*(p1.x*p1.x+p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x+p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
    q = ((p1.x-p2.x)*(p3.y*p3.y-p1.x*p2.x)+(p2.x-p3.x)*(p1.y*p1.y-p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y-p3.x*p1.x)) / ((-2)*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
    return Point_Class(p, q)

def calcRadius(p, pc):
    return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pc = calcCenter(p1, p2, p3)
    r = calcRadius(p1, pc)
    print "%f %f %f" %(pc.x, pc.y, r)

Submission status: Wrong Answer

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

import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def calcCenter(p1, p2, p3):
    p = ((p1.y-p2.y)*(p3.x*p3.x+p1.y*p2.y)+(p2.y-p3.y)*(p1.x*p1.x+p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x+p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
    q = ((p1.x-p2.x)*(p3.y*p3.y+p1.x*p2.x)+(p2.x-p3.x)*(p1.y*p1.y+p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y+p3.x*p1.x)) / ((-2)*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
    return Point_Class(p, q)

def calcRadius(p, pc):
    return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pc = calcCenter(p1, p2, p3)
    r = calcRadius(p1, pc)
    print "%f %f %f" %(pc.x, pc.y, r)

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, -x**2 - y**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(round(x, 3), round(y, 3), round(r, 3))

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, -x**2 - y**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(-round(x, 3), -round(y, 3), round(r, 3))

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, -x**2 - y**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)))