s_id
stringlengths 10
10
| p_id
stringlengths 6
6
| u_id
stringlengths 10
10
| date
stringlengths 10
10
| language
stringclasses 1
value | original_language
stringclasses 11
values | filename_ext
stringclasses 1
value | status
stringclasses 1
value | cpu_time
int64 0
100
| memory
stringlengths 4
6
| code_size
int64 15
14.7k
| code
stringlengths 15
14.7k
| problem_id
stringlengths 6
6
| problem_description
stringlengths 358
9.83k
| input
stringlengths 2
4.87k
| output
stringclasses 807
values | __index_level_0__
int64 1.1k
1.22M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s655711077
|
p00010
|
u150984829
|
1525319480
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5676
| 268
|
for _ in[0]*int(input()):
a,b,c,d,e,f=map(float,input().split())
s,t,u=a*a+b*b,c*c+d*d,e*e+f*f
x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
print(f'{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}')
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,202
|
s514957818
|
p00010
|
u724548524
|
1525742872
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5692
| 526
|
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("{:.3f} {:.3f} {:.3f}".format(p, q, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,203
|
s441020577
|
p00010
|
u724548524
|
1525742882
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5676
| 446
|
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("{:.3f} {:.3f} {:.3f}".format(p, q, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,204
|
s642943574
|
p00010
|
u326929999
|
1527147886
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5708
| 1,196
|
# -*- 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)
x = -tmp[0]/2
y = -tmp[1]/2
r = sqrt((tmp[0]**2 + tmp[1]**2 - 4*tmp[2])/4)
print('{:.3f} {:.3f} {:.3f}'.format(x, y, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,205
|
s975589080
|
p00010
|
u467175809
|
1528378439
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5700
| 679
|
#!/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 func(x):
x1, y1, x2, y2, x3, y3 = x
a = x1 - x2
b = y1 - y2
c = (x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) / 2
d = x1 - x3
e = y1 - y3
f = (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3) / 2
x = (e * c - b * f) / (a * e - b * d)
y = (a * f - d * c) / (a * e - b * d)
r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y))
x = "{0:.3f}".format(g(x))
y = "{0:.3f}".format(g(y))
r = "{0:.3f}".format(g(r))
print(x + " " + y + " " + r)
n = int(input())
a = []
for _ in range(n):
a.append(list((map(float, input().split()))))
for i in a:
func(i)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,206
|
s051503729
|
p00010
|
u467175809
|
1528379662
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5692
| 647
|
#!/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 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) * (x1 - x) + (y1 - y) * (y1 - y))
x = "{0:.3f}".format(g(x))
y = "{0:.3f}".format(g(y))
r = "{0:.3f}".format(g(r))
print(x + " " + y + " " + r)
n = int(input())
a = []
for _ in range(n):
a.append(list((map(float, input().split()))))
for i in a:
func(i)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,207
|
s478922477
|
p00010
|
u458530128
|
1528379879
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5704
| 1,042
|
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))
'''
def f(x):
x1, y1, x2, y2, x3, y3 = x
X1 = x1 - x3
Y1 = y1 - y3
X2 = x2 - x3
Y2 = y2 - y3
k = (X2 ** 2 + Y2 ** 2 -X1 * X2 - Y1 * Y2) / (2 * (X2 * Y1 - X1 * Y2))
X = X1 / 2 + k * Y1 + x3
Y = Y1 / 2 - k * X1 + y3
R = sqrt((X - x1) ** 2 + (Y - y1) ** 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)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,208
|
s609033297
|
p00010
|
u467175809
|
1528380125
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5680
| 546
|
#!/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 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())))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,209
|
s759661770
|
p00010
|
u136916346
|
1528899810
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6484
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,210
|
s534621106
|
p00010
|
u136916346
|
1528899823
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6480
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,211
|
s698981463
|
p00010
|
u136916346
|
1528899828
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6480
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,212
|
s538044268
|
p00010
|
u136916346
|
1528899829
|
Python
|
Python3
|
py
|
Accepted
| 40
|
6480
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,213
|
s311413797
|
p00010
|
u136916346
|
1528899829
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6484
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,214
|
s692554708
|
p00010
|
u136916346
|
1528899829
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6480
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,215
|
s496620189
|
p00010
|
u136916346
|
1528899833
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6484
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,216
|
s250104826
|
p00010
|
u136916346
|
1528899833
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6480
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,217
|
s456613937
|
p00010
|
u136916346
|
1528899833
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6480
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,218
|
s120419056
|
p00010
|
u136916346
|
1528899833
|
Python
|
Python3
|
py
|
Accepted
| 40
|
6484
| 436
|
from decimal import Decimal
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
a=x1-x3
b=y2-y3
c=x2-x3
d=y1-y3
e=y1-y2
f=x1+x3
g=x2+x3
X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
try:
Y=-(a/d)*(X-f/2)+(y1+y3)/2
except:
Y=-(c/b)*(X-g/2)+(y2+y3)/2
R=math.sqrt((x1-X)**2+(y1-Y)**2)
print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,219
|
s959923226
|
p00010
|
u847467233
|
1529634902
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5692
| 945
|
# AOJ 0010 Circumscribed Circle of a Triangle
# Python3 2018.6.22 bal4u
import math
EPS = 1e-8
def cross(a, b):
return a.real*b.imag - a.imag*b.real
def dist(a, b):
return math.hypot(a.real-b.real, a.imag-b.imag)
# 両直線の交点
def crossPointLL(ln1, ln2):
u = ln1[1]-ln1[0]
v = ln2[1]-ln2[0]
return ln1[0] + u*(cross(v, ln2[0]-ln1[0])/cross(v, u))
# 入力:3点座標、リターン:外接円の円心座標、半径を表すリスト
def circumscribed_circle(p1, p2, p3):
p12 = (p1+p2)/2
p23 = (p2+p3)/2
ln1 = [p12, p12+(p1-p2)*complex(0, 1)]
ln2 = [p23, p23+(p2-p3)*complex(0, 1)]
c = crossPointLL(ln1, ln2)
return [c, dist(c, p1)]
for i in range(int(input())):
p = list(map(float, input().split()))
p1 = complex(p[0], p[1])
p2 = complex(p[2], p[3])
p3 = complex(p[4], p[5])
ans = circumscribed_circle(p1, p2, p3)
print(format(ans[0].real+EPS, ".3f"), format(ans[0].imag+EPS, ".3f"), format(ans[1]+EPS, ".3f"))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,220
|
s259787433
|
p00010
|
u650035614
|
1530633618
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5836
| 2,681
|
import math
PI = math.pi
EPS = 10**-10
def edge(a, b):
return ((a[0]-b[0])**2+(a[1]-b[1])**2)**.5
def area(a, b, c):
s = (a+b+c)/2
return (s*(s-a)*(s-b)*(s-c))**.5
def LawOfCosines(a, b, c): #余弦定理
return math.acos( (b*b+c*c-a*a) / (2.0*b*c) );
def is_same(x, y):
return abs(x-y) < EPS
class Triangle:
def __init__(self, p):
a, b, c = p
self.a = a
self.b = b
self.c = c
self.edgeA = edge(b, c)
self.edgeB = edge(c, a)
self.edgeC = edge(a, b)
self.area = area(self.edgeA, self.edgeB, self.edgeC)
self.angleA = LawOfCosines(self.edgeA, self.edgeB, self.edgeC)
self.angleB = LawOfCosines(self.edgeB, self.edgeC, self.edgeA)
self.angleC = LawOfCosines(self.edgeC, self.edgeA, self.edgeB)
def circumscribeadCircleRadius(self): #外接円の半径を返す
return self.edgeA / math.sin(self.angleA) / 2.0
def circumscribedCircleCenter(self): #外接円の中心の座標を返す
a = math.sin(2.0*self.angleA);
b = math.sin(2.0*self.angleB);
c = math.sin(2.0*self.angleC);
X = (self.a[0] * a + self.b[0] * b + self.c[0] * c) / (a+b+c);
Y = (self.a[1] * a + self.b[1] * b + self.c[1] * c) / (a+b+c);
return X, Y
def inscribedCircleRadius(self): #内接円の半径
return 2 * self.area / (self.edgeA + self.edgeB + self.edgeC)
def inscribedCircleCenter(self): #内接円の中心の座標
points = [self.a, self.b, self.c]
edges = [self.edgeA, self.edgeB, self.edgeC]
s = sum(edges)
return [sum([points[j][i]*edges[j] for j in range(3)])/s for i in range(2)]
def isInner(self, p): #点が三角形の内側か判定
cross = lambda a, b: a[0]*b[1]-a[1]*b[0]
c1 = 0
c2 = 0
points = [self.a, self.b, self.c]
for i in range(3):
a = [points[i][0]-points[(i+1)%3][0], points[i][1]-points[(i+1)%3][1]]
b = [points[i][0]-p[0], points[i][1]-p[1]]
c = cross(a, b)
if c > 0:
c1 += 1
elif c < 0:
c2 += 1
if c1 == 3 or c2 == 3:
return True
else:
return c1+c2 != 3 and (c1 == 0 or c2 == 0)
if __name__ == "__main__":
n = int(input())
for _ in range(n):
points = []
c = list(map(float, input().split()))
points = [(c[i], c[i+1]) for i in range(0, 6, 2)]
t = Triangle(points)
#外接円
x, y = t.circumscribedCircleCenter()
r = t.circumscribeadCircleRadius()
print("{:.3f} {:.3f} {:.3f}".format(x,y,r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,221
|
s684388383
|
p00010
|
u719737030
|
1350999617
|
Python
|
Python
|
py
|
Accepted
| 10
|
5012
| 738
|
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,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])
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,222
|
s639938597
|
p00010
|
u647766105
|
1351000052
|
Python
|
Python
|
py
|
Accepted
| 10
|
5012
| 450
|
import sys
n=input()
for line in sys.stdin:
x=map(float,line.split())[0::2];
y=map(float,line.split())[1::2];
#guilty...
A=x[0]-x[1]
B=y[0]-y[1]
C=x[1]-x[2]
D=y[1]-y[2]
E=-(x[0]**2+y[0]**2)+(x[1]**2+y[1]**2)
F=-(x[1]**2+y[1]**2)+(x[2]**2+y[2]**2)
l=(D*E-B*F)/(A*D-B*C)
m=(-C*E+A*F)/(A*D-B*C)
n=-(x[0]**2+y[0]**2+l*x[0]+m*y[0])
print "{:.3f} {:.3f} {:.3f}".format(-l/2,-m/2,(l**2+m**2-4*n)**0.5/2)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,223
|
s199572648
|
p00010
|
u779627195
|
1352473054
|
Python
|
Python
|
py
|
Accepted
| 10
|
52000
| 1,322
|
#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
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,224
|
s354229444
|
p00010
|
u504990413
|
1353585518
|
Python
|
Python
|
py
|
Accepted
| 20
|
4368
| 635
|
def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
def gaishin(a,b,c,z1,z2,z3,s):
p = (a**2*(b**2 + c**2 - a**2)*z1 + \
b**2*(c**2 + a**2 - b**2)*z2 + \
c**2*(a**2 + b**2 - c**2)*z3)/(16*s**2)
return p
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 = gaishin(l1,l2,l3,x1,x2,x3,s)
py = gaishin(l1,l2,l3,y1,y2,y3,s)
r = ((px-x1)**2+(py-y1)**2)**0.5
print '%.3f %.3f %.3f' % (px,py,r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,225
|
s455473437
|
p00010
|
u419407022
|
1355379547
|
Python
|
Python
|
py
|
Accepted
| 20
|
5068
| 502
|
import math
from math import *
for i in range(int(raw_input())):
(x1, y1, x2, y2, x3, y3) = map(float, raw_input().split())
a1 = 2 * (x2 - x1)
b1 = 2 * (y2 - y1)
c1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
a2 = 2 * (x3 - x1)
b2 = 2 * (y3 - y1)
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 = sqrt((x1 - xp) ** 2 + (y1 - yp) ** 2)
print '%.3f %.3f %.3f' % (xp, yp, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,226
|
s009430967
|
p00010
|
u560838141
|
1356696972
|
Python
|
Python
|
py
|
Accepted
| 10
|
4588
| 744
|
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,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])
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,227
|
s390661659
|
p00010
|
u560838141
|
1356697593
|
Python
|
Python
|
py
|
Accepted
| 20
|
4584
| 744
|
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,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])
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,228
|
s582779443
|
p00010
|
u560838141
|
1356697682
|
Python
|
Python
|
py
|
Accepted
| 10
|
4584
| 744
|
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,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])
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,229
|
s192876141
|
p00010
|
u560838141
|
1356699621
|
Python
|
Python
|
py
|
Accepted
| 10
|
4584
| 744
|
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,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])
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,230
|
s725673573
|
p00010
|
u782850731
|
1361937074
|
Python
|
Python
|
py
|
Accepted
| 10
|
4472
| 707
|
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
from math import sqrt
N = int(stdin.readline())
for i in xrange(N):
x1, y1, x2, y2, x3, y3 = (float(n) for n in stdin.readline().split())
det = x1*y2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 - x3*y2
a = x1**2 + y1**2
b = x2**2 + y2**2
c = x3**2 + y3**2
L = (a*y2 + b*y3 + c*y1 - a*y3 - b*y1 - c*y2) / det
M = (x1*b + x2*c + x3*a - x1*c - x2*a - x3*b) / det
N = (x1*y2*c + x2*y3*a + x3*y1*b - x1*y3*b - x2*y1*c - x3*y2*a) / det
xp = L / 2.0
yp = M / 2.0
r = sqrt(abs(N + xp**2.0 + yp**2.0))
print('{:.3f} {:.3f} {:.3f}'.format(xp, yp, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,231
|
s574348966
|
p00010
|
u575065019
|
1362255903
|
Python
|
Python
|
py
|
Accepted
| 20
|
4440
| 431
|
from math import sqrt
ans=[]
n=input()
for i in xrange(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().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
x=(B1*C2-B2*C1)/(A1*B2-A2*B1)
y=(C1*A2-C2*A1)/(A1*B2-A2*B1)
r=sqrt((x-x1)**2 + (y-y1)**2)
ansstr='%.3f %.3f %.3f' % (x,y,r)
ans.append(ansstr)
for i in ans:
print i
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,232
|
s526999589
|
p00010
|
u585414111
|
1365788031
|
Python
|
Python
|
py
|
Accepted
| 10
|
4452
| 546
|
import sys
from math import sqrt
n = input()
for line in sys.stdin:
[x1,y1,x2,y2,x3,y3] = [float(x) for x in line.split()]
a1 = 2*(x2-x1)
b1 = 2*(y2-y1)
c1 = x1**2-x2**2+y1**2-y2**2
a2 = 2*(x3-x1)
b2 = 2*(y3-y1)
c2 = x1**2-x3**2+y1**2-y3**2
x = (b1*c2-b2*c1)/(a1*b2-a2*b1)
y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
a = sqrt((x2-x1)**2 + (y2-y1)**2)
b = sqrt((x3-x1)**2 + (y3-y1)**2)
c = sqrt((x3-x2)**2 + (y3-y2)**2)
r = (a*b*c)/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c))
print "%.3f %.3f %.3f" % (x,y,r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,233
|
s911748786
|
p00010
|
u350508326
|
1368049459
|
Python
|
Python
|
py
|
Accepted
| 10
|
4416
| 464
|
import math
a = int(raw_input())
while a > 0:
a -= 1
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
a1 = 2*(x2-x1)
b1 = 2*(y2-y1)
c1 = x1*x1-x2*x2+y1*y1-y2*y2
a2 = 2*(x3-x1)
b2 = 2*(y3-y1)
c2 = x1*x1-x3*x3+y1*y1-y3*y3
X = (b1*c2-b2*c1)/(a1*b2-a2*b1)
Y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
R = math.sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1))
print "%.3f %.3f %.3f" % (X,Y,R)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,234
|
s904662742
|
p00010
|
u454358619
|
1377381157
|
Python
|
Python
|
py
|
Accepted
| 20
|
4412
| 415
|
import math
a = int(raw_input())
while a > 0:
a -= 1
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
a1 = 2*(x2-x1)
b1 = 2*(y2-y1)
c1 = x1*x1-x2*x2+y1*y1-y2*y2
a2 = 2*(x3-x1)
b2 = 2*(y3-y1)
c2 = x1*x1-x3*x3+y1*y1-y3*y3
X = (b1*c2-b2*c1)/(a1*b2-a2*b1)
Y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
R = math.sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1))
print "%.3f %.3f %.3f" % (X,Y,R)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,235
|
s241429082
|
p00010
|
u912237403
|
1377393344
|
Python
|
Python
|
py
|
Accepted
| 10
|
4484
| 686
|
import math
def equation(A):
n = len(A)
for i in range(n):
j=i
while A[j][i]==0:
j+= 1
A[i], A[j] = A[j], A[i]
A[i] = [e / A[i][i] for e in A[i]]
for j in range(n):
if j==i: continue
tmp = A[j][i]
for k in range(n+1):
A[j][k] -= tmp * A[i][k]
return
n=input()
for i in range(n):
A=[]
seq = map(float, raw_input().split())
for j in range(3):
x = seq.pop(0)
y = seq.pop(0)
A.append([x, y, 1, -(x**2+y**2)])
equation(A)
x0, y0 = -A[0][3]/2, -A[1][3]/2
r =((x-x0)**2 + (y-y0)**2)**.5
print "%.3f %.3f %.3f" %(x0, y0, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,236
|
s336615626
|
p00010
|
u813384600
|
1379493227
|
Python
|
Python
|
py
|
Accepted
| 20
|
4432
| 466
|
import math
n = int(raw_input())
for _ in range(n):
(x1, y1, x2, y2, x3, y3) = map(float, raw_input().split())
a1 = (x2 - x1) * 2
a2 = (x3 - x1) * 2
b1 = (y2 - y1) * 2
b2 = (y3 - y1) * 2
c1 = x1**2 - x2**2 + y1**2 - y2**2
c2 = x1**2 - x3**2 + y1**2 - y3**2
x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1)
y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1)
r = math.sqrt((x-x1)**2 + (y-y1)**2)
print '{0:.3f} {1:.3f} {2:.3f}'.format(x, y, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,237
|
s831575306
|
p00010
|
u492005863
|
1381406358
|
Python
|
Python
|
py
|
Accepted
| 10
|
4420
| 570
|
# -*- coding: utf-8 -*-
import sys
import math
n = 0
datas = []
for (i, line) in enumerate(sys.stdin):
if i == 0:
n = int(line)
else:
datas.append(map(float, line.split()))
for data in datas:
x1, y1, x2, y2, x3, y3 = data
a1 = x2 - x1
b1 = y2 - y1
a2 = x3 - x1
b2 = y3 - y1
px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
r = math.sqrt(px * px + py * py)
px += x1
py += y1
print "{0:.3f} {1:.3f} {2:.3f}".format(px, py, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,238
|
s678331748
|
p00010
|
u492005863
|
1381406942
|
Python
|
Python
|
py
|
Accepted
| 20
|
4416
| 583
|
# Circumscribed Circle of a Triangle
import sys
import math
n = 0
datas = []
for (i, line) in enumerate(sys.stdin):
if i == 0:
n = int(line)
else:
datas.append(map(float, line.split()))
for data in datas:
x1, y1, x2, y2, x3, y3 = data
a1 = x2 - x1
b1 = y2 - y1
a2 = x3 - x1
b2 = y3 - y1
px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
r = math.sqrt(px * px + py * py)
px += x1
py += y1
print "{0:.3f} {1:.3f} {2:.3f}".format(px, py, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,239
|
s001056118
|
p00010
|
u621997536
|
1388943330
|
Python
|
Python
|
py
|
Accepted
| 10
|
4412
| 496
|
import math
n = input()
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
d1 = x1 * x1 + y1 * y1;
d2 = x2 * x2 + y2 * y2;
d3 = x3 * x3 + y3 * y3;
u = 0.5 / ( x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3)
xp = u* (d1 * y2 - d2 * y1 + d2 * y3 - d3 * y2 + d3 * y1 - d1 * y3)
yp = u * (x1 * d2 - x2 * d1 + x2 * d3 - x3 * d2 + x3 * d1 - x1 * d3)
r = math.sqrt((xp - x1) * (xp - x1) + (yp - y1) * (yp - y1))
print "%.3f %.3f %.3f" % (xp, yp, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,240
|
s148157877
|
p00010
|
u912237403
|
1390145097
|
Python
|
Python
|
py
|
Accepted
| 10
|
4500
| 534
|
import math
def equation(A):
n=len(A)
for i in range(n):
j=i
while A[j][i]==0:j+=1
A[i],A[j]= A[j],A[i]
A[i]=[e/A[i][i] for e in A[i]]
for j in range(n):
if j==i: continue
tmp=A[j][i]
for k in range(n+1):A[j][k]-=tmp*A[i][k]
return
n=input()
for i in range(n):
A=[]
seq=map(float,raw_input().split())
for j in range(0,6,2):
x,y=seq[j:j+2]
A+=[[x,y,1,-(x**2+y**2)]]
equation(A)
x0=-A[0][3]/2
y0=-A[1][3]/2
r=((x-x0)**2+(y-y0)**2)**.5
print "%.3f %.3f %.3f" %(x0,y0,r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,241
|
s460236051
|
p00010
|
u230836528
|
1392272869
|
Python
|
Python
|
py
|
Accepted
| 10
|
4464
| 1,731
|
# -*- coding: utf-8 -*-
import sys
def prod_mat_vec(A, vec):
ret = [0 for i in xrange(3)]
for i in xrange(3):
for j in xrange(3):
ret[i] += A[i][j] * vec[j]
return ret
def changerow(A, i1, i2):
for j in xrange(3):
buf = A[i1][j]
A[i1][j] = A[i2][j]
A[i2][j] = buf
return A
def MatrixInverse3x3(A_src):
A = [ [A_src[i][j] for j in xrange(3)] for i in xrange(3) ] # deepcopy A_src -> A
B = [ [1, 0, 0], \
[0, 1, 0], \
[0, 0, 1] ]
for i in xrange(3):
if A[i][i] == 0:
for k in xrange(i+1, 3):
if A[k][k] != 0:
A = changerow(A, i, k)
B = changerow(B, i, k)
a = A[i][i]
for j in xrange(3):
A[i][j] /= a
B[i][j] /= a
for k in xrange(3):
if i == k: continue
a = A[k][i]
for j in xrange(3):
A[k][j] -= A[i][j] * a
B[k][j] -= B[i][j] * a
return B
def output3x3(A):
for i in xrange(3):
print "%7.3f %7.3f %7.3f" % (A[i][0], A[i][1], A[i][2])
return
#for line in ["0.0 3.0 -1.0 0.0 -3.0 4.0"]: # expected [-2.000, 2.000, 2.236]
for line in sys.stdin.readlines():
List = map(float, line.strip().split())
if len(List) == 1: continue
[x1, y1, x2, y2, x3, y3] = List
A = [ [x1, y1, 1.0] ,\
[x2, y2, 1.0] ,\
[x3, y3, 1.0] ]
vec = [x1**2+y1**2, x2**2+y2**2, x3**2+y3**2]
B = MatrixInverse3x3(A)
lmn = prod_mat_vec(B, vec)
ans = [0.5*lmn[0], 0.5*lmn[1], (lmn[2]+0.25*lmn[0]**2+0.25*lmn[1]**2)**0.5]
print "%.3f %.3f %.3f" % (ans[0], ans[1], ans[2])
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,242
|
s813095975
|
p00010
|
u300645821
|
1392570850
|
Python
|
Python
|
py
|
Accepted
| 10
|
4408
| 382
|
import sys,math
if sys.version_info[0]>=3: raw_input=input
N=int(raw_input())
for i in range(N):
x1,y1,x2,y2,x3,y3=[float(e) for e in raw_input().split()]
a1=2*x2-2*x1
b1=2*y2-2*y1
c1=x1*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,243
|
s612749846
|
p00010
|
u633068244
|
1393356107
|
Python
|
Python
|
py
|
Accepted
| 10
|
4444
| 676
|
import math
n = int(raw_input())
while True:
try:
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
b = math.sqrt((x1-x3)**2+(y1-y3)**2)
c = math.sqrt((x2-x3)**2+(y2-y3)**2)
s = (a+b+c)/2
ss = math.sqrt(s*(s-a)*(s-b)*(s-c))
sina = 2*ss/b/c
sinb = 2*ss/a/c
sinc = 2*ss/a/b
r = a/sina/2
a = a*a
b = b*b
c = c*c
px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/ss**2
py =(a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/ss**2
print "%.3f %.3f %.3f" % (px, py, r)
except:
break
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,244
|
s380242787
|
p00010
|
u633068244
|
1393356248
|
Python
|
Python
|
py
|
Accepted
| 10
|
4444
| 532
|
import math
n = int(raw_input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
b = math.sqrt((x1-x3)**2+(y1-y3)**2)
c = math.sqrt((x2-x3)**2+(y2-y3)**2)
s = (a+b+c)/2
ss = math.sqrt(s*(s-a)*(s-b)*(s-c))
sina = 2*ss/b/c
r = a/sina/2
a = a*a
b = b*b
c = c*c
px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/ss**2
py =(a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/ss**2
print "%.3f %.3f %.3f" % (px, py, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,245
|
s243207823
|
p00010
|
u708217907
|
1398121408
|
Python
|
Python
|
py
|
Accepted
| 20
|
4392
| 467
|
import sys
import math
n = int(raw_input())
for data in sys.stdin:
x1, y1, x2, y2, x3, y3 = map(float, data.split())
a1 = x2 - x1
b1 = y2 - y1
a2 = x3 - x1
b2 = y3 - y1
px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
r = math.sqrt(px * px + py * py)
px += x1
py += y1
print "{0:.3f} {1:.3f} {2:.3f}".format(px, py, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,246
|
s591258207
|
p00010
|
u491763171
|
1400539773
|
Python
|
Python
|
py
|
Accepted
| 10
|
4432
| 560
|
from math import hypot
T = input()
for t in xrange(1, T + 1):
x1, y1, x2, y2, x3, y3 = map(float, raw_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 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) /
(2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3)))
print "%.3f %.3f %.3f" % (x4, y4, hypot(x1 - x4, y1 - y4))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,247
|
s954505556
|
p00010
|
u300645821
|
1400580204
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6828
| 400
|
#!/usr/bin/python
import sys,math
if sys.version_info[0]>=3: raw_input=input
N=int(raw_input())
for i in range(N):
x1,y1,x2,y2,x3,y3=[float(e) for e in raw_input().split()]
a1=2*x2-2*x1
b1=2*y2-2*y1
c1=x1*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,248
|
s479244965
|
p00010
|
u300645821
|
1400580241
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6828
| 382
|
import sys,math
if sys.version_info[0]>=3: raw_input=input
N=int(raw_input())
for i in range(N):
x1,y1,x2,y2,x3,y3=[float(e) for e in raw_input().split()]
a1=2*x2-2*x1
b1=2*y2-2*y1
c1=x1*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,249
|
s532964118
|
p00010
|
u436634575
|
1401130872
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6836
| 451
|
from math import hypot
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().strip().split())
d = lambda x, y: x*x + y*y
t21 = [2*(x2-x1), 2*(y2-y1), d(x2,y2) - d(x1,y1)]
t31 = [2*(x3-x1), 2*(y3-y1), d(x3,y3) - d(x1,y1)]
det = lambda i, j: t21[i]*t31[j] - t21[j]*t31[i]
a = det(2,1) / det(0,1)
b = det(0,2) / det(0,1)
r = hypot(x1-a, y1-b)
print('{:.3f} {:.3f} {:.3f}'.format(a, b, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,250
|
s240476404
|
p00010
|
u813197825
|
1596184640
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5696
| 911
|
def f1(a, b, c, d): # 2点の中心を通り垂直な線の傾きと切片
k = (a - c) / (d - b)
h = ((b + d) - k * (a + c)) / 2
return k, h
def f2(a, b, c, d): # 2直線との交点
x = (d - b) / (a - c)
y = a * x + b
return x, y
def f3(a, b, c, d):
return ((c - a) ** 2 + (d - b) ** 2) ** 0.5
def main():
N = int(input())
for i in range(N):
a, b, c, d, e, f = map(float, input().split())
T = []
if not b == d:
k, h = f1(a, b, c, d)
T.append((k, h))
if not d == f:
k, h = f1(c, d, e, f)
T.append((k, h))
if not f == b:
k, h = f1(e, f, a, b)
T.append((k, h))
x, y = f2(T[0][0], T[0][1], T[1][0], T[1][1])
r = f3(x, y, a, b)
print(f'{round(x, 3):.3f} {round(y, 3):.3f} {round(r, 3):.3f}')
if __name__ == '__main__':
main()
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,251
|
s353335724
|
p00010
|
u187074069
|
1592413271
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5672
| 504
|
n = int(input())
for i in range(n):
lst = list(map(float, input().split()))
a, b = lst[0], lst[1]
c, d = lst[2], lst[3]
e, f = lst[4], lst[5]
px = ((a+c)*(a-c)*(b-f)-(a+e)*(a-e)*(b-d)+(b-d)*(b-f)*(d-f))/(2*((a-c)*(b-f)-(a-e)*(b-d)))
py = ((a-c)*(a-e)*(c-e)+(b+d)*(b-d)*(a-e)-(b+f)*(b-f)*(a-c))/(2*((b-d)*(a-e)-(b-f)*(a-c)))
r = ((a-px)**2 + (b-py)**2)**0.5
print('{:.3f}'.format(px), end= " ")
print('{:.3f}'.format(py), end= " ")
print('{:.3f}'.format(r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,252
|
s120875423
|
p00010
|
u814278309
|
1592268993
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5696
| 432
|
import math
for i in range(int(input())):
x1,y1,x2,y2,x3,y3 = map(float,input().split())
a = 2*(x2 - x1)
b = 2*(y2 - y1)
c = x1**2 - x2**2 + y1**2 - y2**2
aa = 2*(x3 - x1)
bb = 2*(y3 - y1)
cc = x1**2 - x3**2 + y1**2 - y3**2
x = (b*cc - bb*c) / (a*bb - aa*b)
y = (c*aa - cc*a) / (a*bb - aa*b)
r = math.hypot(x1 - x,y1 - y)
print(f'{x:.03f} {y:.03f} {r:.03f}')
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,253
|
s378328852
|
p00010
|
u245861861
|
1592051350
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5688
| 328
|
import math
N=int(input())
for i in range(N):
x1,y1,x2,y2,x3,y3=[float(e) for e in input().split()]
a1=2*x2-2*x1
b1=2*y2-2*y1
c1=x1*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,254
|
s097941839
|
p00010
|
u240091169
|
1589154162
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5688
| 546
|
import math
n = int(input())
for i in range(n) :
x1, y1, x2, y2, x3, y3 = map(float, input().split())
py = ((x3-x1)*(x1**2 + y1**2 - x2**2 - y2**2) - (x2-x1)*(x1**2 + y1**2 - x3**2 - y3**2)) / (2*(x3-x1)*(y1-y2) - 2*(x2-x1)*(y1-y3))
if x1 == x2 :
px = (2*(y1-y3)*py - x1**2 - y1**2 + x3**2 + y3**2) / (2*(x3 - x1))
else :
px = (2*(y1-y2)*py - x1**2 - y1**2 + x2**2 + y2**2) / (2*(x2 - x1))
r = math.sqrt((px - x1)**2 + (py -y1)**2)
print('{:.3f}'.format(px), '{:.3f}'.format(py), '{:.3f}'.format(r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,255
|
s311774112
|
p00010
|
u260980560
|
1588729240
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5656
| 448
|
N = int(input())
for i in range(N):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a = 2*(x1 - x2); b = 2*(y1 - y2); p = x1**2 - x2**2 + y1**2 - y2**2
c = 2*(x1 - x3); d = 2*(y1 - y3); q = x1**2 - x3**2 + y1**2 - y3**2
det = a*d - b*c
x = d*p - b*q; y = a*q - c*p
if det < 0:
x = -x; y = -y; det = -det
x /= det; y /= det
r = ((x - x1)**2 + (y - y1)**2)**.5
print("%.03f %.03f %.03f" % (x, y, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,256
|
s713460365
|
p00010
|
u630911389
|
1576894361
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5692
| 917
|
import math
class Circle:
def __init__(self,x,y,r):
self.x = x
self.y = y
self.r = r
def getCircle(x1, y1, x2, y2, x3, y3):
d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
px = ((x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
py = ((x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
s = (a + b + c) / 2
A = math.sqrt(s * (s - a) * (s - b) * (s - c))
r = a * b * c / (4 * A)
return Circle(px,py,r)
n = int(input())
for k in range(n):
x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split()]
circle = getCircle(x1, y1, x2, y2, x3, y3)
print("%.3f %.3f %.3f" % (circle.x, circle.y, circle.r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,257
|
s518087770
|
p00010
|
u942532706
|
1575467363
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5628
| 419
|
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
a = complex(x1, y1)
b = complex(x2, y2)
c = complex(x3, y3)
a -= c
b -= c
z0 = abs(a)**2 * b - abs(b)**2 * a
z0 /= a.conjugate() * b - a * b.conjugate()
z = z0 + c
zx = "{0:.3f}".format(z.real)
zy = "{0:.3f}".format(z.imag)
r = "{0:.3f}".format(abs(z0))
print(zx, zy, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,258
|
s590285760
|
p00010
|
u350155409
|
1574869000
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5700
| 701
|
import math
n = int(input())
round = lambda x:(x*1000*2+1)//2/1000
for i in range(n):
x1,y1,x2,y2,x3,y3 = [ float(s) for s in input().split() ]
r1 = x1*x1 + y1*y1
r2 = x2*x2 + y2*y2
r3 = x3*x3 + y3*y3
x1_x2 = x1 - x2
y1_y2 = y1 - y2
x1_x3 = x1 - x3
y1_y3 = y1 - y3
r1_r2 = r1 - r2
r1_r3 = r1 - r3
if x1_x2 == 0:
py = r1_r2 / (2*y1_y2)
px = (r1_r3 - 2*y1_y3*py) / (2*x1_x3)
else:
py = (r1_r2 * x1_x3 - r1_r3 * x1_x2) / (2*(y1_y2 * x1_x3 - y1_y3 * x1_x2))
px = (r1_r2 - 2*y1_y2*py) / (2*x1_x2)
r = math.sqrt((x1-px)**2 + (y1-py)**2)
print('{:.3f}'.format(0+px),'{:.3f}'.format(0+py),'{:.3f}'.format(0+round(r)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,259
|
s810921843
|
p00010
|
u072053884
|
1573481484
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5644
| 616
|
def solve():
from sys import stdin
f_i = stdin
n = int(f_i.readline())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, f_i.readline().split())
A = x1 + y1 * 1j
B = x2 + y2 * 1j
C = x3 + y3 * 1j
a = abs(C - B)
b = abs(A - C)
c = abs(B - A)
c1 = a**2 * (b**2 + c**2 - a**2)
c2 = b**2 * (c**2 + a**2 - b**2)
c3 = c**2 * (a**2 + b**2 - c**2)
U = (c1 * A + c2 * B + c3 * C) / (c1 + c2 + c3)
R = abs(U - A)
print('{:.3f} {:.3f} {:.3f}'.format(U.real, U.imag, R))
solve()
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,260
|
s983247562
|
p00010
|
u128808587
|
1571110045
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5672
| 541
|
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
a = 2*(x1-x2)
b = 2*(y1-y2)
c = x1**2 - x2**2 + y1**2 - y2**2
d = 2*(x1-x3)
e = 2*(y1-y3)
f = x1**2 - x3**2 + y1**2 - y3**2
y = (c*d - a*f) / (b*d - a*e)
if a==0:
x = (f - e*y) / d
else:
x = (c - b*y) / a
r = ((x1 - x)**2 + (y1 - y)**2)**0.5
print('{:.3f}'.format(round(x, 3)), end=" ")
print('{:.3f}'.format(round(y, 3)), end=" ")
print('{:.3f}'.format(round(r, 3)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,261
|
s253801764
|
p00010
|
u586792237
|
1564930121
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5688
| 684
|
import math
n = int(input())
positions = []
for i in range(n):
positions.append(list(map(float, input().split())))
for i in range(n):
ra = [positions[i][0],positions[i][1]]
rb = [positions[i][2],positions[i][3]]
rc = [positions[i][4],positions[i][5]]
A = (rb[0]-rc[0])**2+(rb[1]-rc[1])**2
B = (rc[0]-ra[0])**2+(rc[1]-ra[1])**2
C = (ra[0]-rb[0])**2+(ra[1]-rb[1])**2
P = A * (B+C-A)
Q = B * (C+A-B)
R = C * (A+B-C)
rcc_x = (P*ra[0] + Q*rb[0] + R*rc[0]) / (P+Q+R)
rcc_y = (P*ra[1] + Q*rb[1] + R*rc[1]) / (P+Q+R)
radius = math.sqrt((rcc_x-positions[i][0])**2+(rcc_y-positions[i][1])**2)
print("{0:.3f} {1:.3f} {2:.3f}".format(rcc_x,rcc_y,radius))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,262
|
s063542268
|
p00010
|
u821561321
|
1564924113
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5680
| 304
|
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a,b,c=2*(x2-x1),2*(y2-y1),x1**2-x2**2+y1**2-y2**2
aa,bb,cc=2*(x3-x1),2*(y3-y1),x1**2-x3**2+y1**2-y3**2
x,y=(b*cc-bb*c)/(a*bb-aa*b),(c*aa-cc*a)/(a*bb-aa*b)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,263
|
s083090877
|
p00010
|
u427219397
|
1564893135
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5684
| 447
|
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("{:.3f} {:.3f} {:.3f}".format(p, q, r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,264
|
s610729218
|
p00010
|
u678843586
|
1564643799
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5680
| 314
|
import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a,b,c=2*(x2-x1),2*(y2-y1),x1**2-x2**2+y1**2-y2**2
aa,bb,cc=2*(x3-x1),2*(y3-y1),x1**2-x3**2+y1**2-y3**2
x,y=(b*cc-bb*c)/(a*bb-aa*b),(c*aa-cc*a)/(a*bb-aa*b)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,265
|
s024363287
|
p00010
|
u647694976
|
1564453627
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5680
| 413
|
import sys,math
if sys.version_info[0]>=3: raw_input=input
N=int(raw_input())
for i in range(N):
x1,y1,x2,y2,x3,y3=[float(e) for e in raw_input().split()]
a1=2*x2-2*x1
b1=2*y2-2*y1
c1=x1*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,266
|
s655021020
|
p00010
|
u264450287
|
1561506812
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5704
| 434
|
import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a=(x3-x1)*(x1**2+y1**2-x2**2-y2**2)-(x2-x1)*(x1**2+y1**2-x3**2-y3**2)
b=2*(x3-x1)*(y1-y2)-2*(x2-x1)*(y1-y3)
py=a/b
if x2-x1!=0:
px=(2*(y1-y2)*py-x1**2-y1**2+x2**2+y2**2)/(2*(x2-x1))
else:
px=(2*(y1-y3)*py-x1**2-y1**2+x3**2+y3**2)/(2*(x3-x1))
r=math.sqrt((px-x1)**2+(py-y1)**2)
print(f"{px:.3f}",f"{py:.3f}",f"{r:.3f}")
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,267
|
s064594237
|
p00010
|
u625806423
|
1553686965
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5692
| 677
|
import math
n = int(input())
positions = []
for i in range(n):
positions.append(list(map(float, input().split())))
for i in range(n):
ra = [positions[i][0],positions[i][1]]
rb = [positions[i][2],positions[i][3]]
rc = [positions[i][4],positions[i][5]]
A = (rb[0]-rc[0])**2+(rb[1]-rc[1])**2
B = (rc[0]-ra[0])**2+(rc[1]-ra[1])**2
C = (ra[0]-rb[0])**2+(ra[1]-rb[1])**2
P = A * (B+C-A)
Q = B * (C+A-B)
R = C * (A+B-C)
rcc_x = (P*ra[0] + Q*rb[0] + R*rc[0]) / (P+Q+R)
rcc_y = (P*ra[1] + Q*rb[1] + R*rc[1]) / (P+Q+R)
radius = math.sqrt((rcc_x-positions[i][0])**2+(rcc_y-positions[i][1])**2)
print("{0:.3f} {1:.3f} {2:.3f}".format(rcc_x,rcc_y,radius))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,268
|
s405716502
|
p00010
|
u990228206
|
1553159380
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6452
| 555
|
from decimal import Decimal, ROUND_HALF_UP
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a=2*(x1-x2)
b=2*(y1-y2)
c=x1**2+y1**2-x2**2-y2**2
d=2*(x1-x3)
e=2*(y1-y3)
f=x1**2+y1**2-x3**2-y3**2
x=(c*e-b*f)/(a*e-b*d)+0.0
y=(c*d-a*f)/(b*d-a*e)+0.0
r=((x-x1)**2+(y-y1)**2)**0.5
print(Decimal(str(x)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(y)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(r)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,269
|
s214732147
|
p00010
|
u563075864
|
1542255049
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5716
| 846
|
n = int(input())
import math
for _ in range(n):
ax,ay,bx,by,cx,cy = [float(i) for i in input().split()]
ab = math.sqrt((ax-bx)**2+(ay-by)**2)
bc = math.sqrt((bx-cx)**2+(by-cy)**2)
ca = math.sqrt((cx-ax)**2+(cy-ay)**2)
cos_a = (ab**2+ca**2-bc**2)/(2*ab*ca)
sin_a = math.sqrt(1-cos_a**2)
r = bc/(2*sin_a)
px = ((ay-cy)*(ay**2 -by**2 +ax**2 -bx**2) -(ay-by)*(ay**2 -cy**2 +ax**2 -cx**2)) / (2*(ay-cy)*(ax-bx)-2*(ay-by)*(ax-cx))
py = ((ax-cx)*(ax**2 -bx**2 +ay**2 -by**2) -(ax-bx)*(ax**2 -cx**2 +ay**2 -cy**2)) / (2*(ax-cx)*(ay-by)-2*(ax-bx)*(ay-cy))
def round3(x):
x_ = x*10**3
if x_%1 < 0.5:
x_ = math.floor(x_)
else:
x_ = math.ceil(x_)
return x_*10**(-3)
print("{:.3f} {:.3f} {:.3f}".format(round3(px),round3(py),round3(r)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,270
|
s460477095
|
p00010
|
u717526540
|
1541638764
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6504
| 793
|
import math
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a2 = (x2-x3)**2 + (y2-y3)**2
b2 = (x1-x3)**2 + (y1-y3)**2
c2 = (x1-x2)**2 + (y1-y2)**2
area = ((x2-x1) * (y3-y1) - (x3-x1) * (y2-y1)) / 2
x = (a2*(b2+c2-a2)*x1 + b2*(c2+a2-b2) *
x2 + c2*(a2+b2-c2)*x3) / (16*area*area)
y = (a2*(b2+c2-a2)*y1 + b2*(c2+a2-b2) *
y2 + c2*(a2+b2-c2)*y3) / (16*area*area)
r = ((x1-x)**2 + (y1-y)**2)**0.5
x = Decimal(str(x)).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
y = Decimal(str(y)).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
r = Decimal(str(r)).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
print(x, y, r)
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,271
|
s889700742
|
p00010
|
u509278866
|
1536567358
|
Python
|
Python3
|
py
|
Accepted
| 70
|
9056
| 1,944
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def distance(x1, y1, x2, y2):
return math.sqrt((x1-x2)**2 + (y1-y2)**2)
def intersection(a1, a2, b1, b2):
x1,y1 = a1
x2,y2 = a2
x3,y3 = b1
x4,y4 = b2
ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1)
eta = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1)
delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3)
if delta == 0:
return None
ramda = ksi / delta;
mu = eta / delta;
if ramda >= 0 and ramda <= 1 and mu >= 0 and mu <= 1:
return (x1 + ramda * (x2 - x1), y1 + ramda * (y2 - y1))
return None
def circumcenters(a,b,c):
t1 = [(a[0]+b[0])/2, (a[1]+b[1])/2]
s1 = [t1[1]-a[1], a[0]-t1[0]]
t2 = [(a[0]+c[0])/2, (a[1]+c[1])/2]
s2 = [t2[1]-a[1], a[0]-t2[0]]
p1 = [t1[0]+s1[0]*1e7, t1[1]+s1[1]*1e7]
p2 = [t1[0]-s1[0]*1e7, t1[1]-s1[1]*1e7]
p3 = [t2[0]+s2[0]*1e7, t2[1]+s2[1]*1e7]
p4 = [t2[0]-s2[0]*1e7, t2[1]-s2[1]*1e7]
return intersection(p1,p2,p3,p4)
def main():
n = I()
rr = []
for _ in range(n):
x1,y1,x2,y2,x3,y3 = LF()
a = [x1,y1]
b = [x2,y2]
c = [x3,y3]
t = circumcenters(a,b,c)
rr.append('{:0.3f} {:0.3f} {:0.3f}'.format(t[0], t[1], distance(t[0],t[1],x1,y1)))
return '\n'.join(rr)
print(main())
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,272
|
s685092580
|
p00010
|
u319725914
|
1534213490
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5660
| 446
|
n = int(input())
for _ in range(n):
x1,y1,x2,y2,x3,y3 = map(float, input().split())
gx = (x1+x2+x3)/3
gy = (y1+y2+y3)/3
G=( y2*x1-y1*x2 +y3*x2-y2*x3 +y1*x3-y3*x1 )
Xc= ((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(2*G)
Yc=-((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(2*G)
r = ( (x1 - Xc) * (x1 - Xc) + (y1 - Yc) * (y1 - Yc) )**0.5
print("%.3f %.3f %.3f"%(Xc,Yc,r))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,273
|
s492145493
|
p00010
|
u252700163
|
1532751394
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5688
| 789
|
def circumcenter(vert1, vert2, vert3):
# H/T: wikipedia.org/wiki/Circumscribed_circle
# refer from https://gist.github.com/dhermes/9ce057da49df63345c33
Ax, Ay = vert1
Bx, By = vert2
Cx, Cy = vert3
D = 2 * (Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By))
norm_A = Ax**2 + Ay**2
norm_B = Bx**2 + By**2
norm_C = Cx**2 + Cy**2
Ux = norm_A * (By - Cy) + norm_B * (Cy - Ay) + norm_C * (Ay - By)
Uy = -(norm_A * (Bx - Cx) + norm_B * (Cx - Ax) + norm_C * (Ax - Bx))
r = (Ax - Ux/D)*(Ax - Ux/D) + (Ay - Uy/D)* (Ay - Uy/D)
r = float(r)**0.5
return [Ux/D, Uy/D, r]
n = int(input())
for i in range(n):
xs = list(map(float, input().split()))
a = circumcenter(xs[0:2], xs[2:4], xs[4:6])
print(' '.join(map(lambda x:f'{x:0.03f}', a)))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,274
|
s545516481
|
p00010
|
u853158149
|
1521969543
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5676
| 552
|
n = int(input())
ans = []
for i in range(n):
ax,ay,bx,by,cx,cy = map(float, input().split(" "))
a,b,c = 2*(ax-bx),2*(ay-by),(ax+bx)*(ax-bx)+(ay+by)*(ay-by)
d,e,f = 2*(ax-cx),2*(ay-cy),(ax+cx)*(ax-cx)+(ay+cy)*(ay-cy)
det = a*e-b*d
px = (c*e-b*f)/det
py = (a*f-c*d)/det
if abs(px) < 1e-4:
px = 0.0
if abs(py) < 1e-4:
py = 0.0
r = ((ax-px)**2+(ay-py)**2)**(1/2)
ans.append([px,py,r])
for i in range(n):
print("{0:.3f}".format(ans[i][0]),"{0:.3f}".format(ans[i][1]),"{0:.3f}".format(ans[i][2]))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,275
|
s412598109
|
p00010
|
u079141094
|
1467343394
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7748
| 967
|
# Circumscribed Circle of a Triangle
import math
def simul_eq(a,b,c,d,e,f):
# A = [[a,b],[d,e]]
C = [c,f]
detA = a*e - b*d
# if detA == 0: raise # det(A) == 0.
At = [[e,-b],[-d,a]]
x = sum(map((lambda x,y: x*y), At[0], C)) / detA
y = sum(map((lambda x,y: x*y), At[1], C)) / detA
fx,fy = '{0:.3f}'.format(x), '{0:.3f}'.format(y)
if fx == '-0.000': fx = fx[1:]
if fy == '-0.000': fy = fy[1:]
return (fx,fy)
n = int(input())
for _ in range(n):
x1,y1,x2,y2,x3,y3 = map(float, input().split())
a = math.sqrt(pow(x2-x3, 2) + pow(y2-y3, 2))
b = math.sqrt(pow(x1-x3, 2) + pow(y1-y3, 2))
c = math.sqrt(pow(x2-x1, 2) + pow(y2-y1, 2))
cosA = (pow(b,2) + pow(c,2) - pow(a,2)) / (2*b*c)
sinA = math.sqrt(1 - pow(cosA,2))
R = a / (2 * sinA)
cen = simul_eq(x2-x1, y2-y1, (y2**2 - y1**2 + x2**2 - x1**2) / 2, x3-x1, y3-y1, (y3**2 - y1**2 + x3**2 - x1**2) / 2)
print(' '.join(cen), '{0:.3f}'.format(R))
|
p00010
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
1
0.0 0.0 2.0 0.0 2.0 2.0
|
1.000 1.000 1.414
| 5,276
|
s665570502
|
p00011
|
u995990363
|
1530849871
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5604
| 280
|
def run():
w = [i + 1 for i in range(int(input()))]
n = int(input())
for _ in range(n):
s1, s2 = list(map(int, input().split(',')))
w[s1-1], w[s2-1] = w[s2-1], w[s1-1]
print('\n'.join([str(_w) for _w in w]))
if __name__ == '__main__':
run()
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,277
|
s003690790
|
p00011
|
u733620181
|
1408923815
|
Python
|
Python
|
py
|
Accepted
| 10
|
4208
| 203
|
import sys
n = int(sys.stdin.readline())
sys.stdin.readline()
l = range(1, n+1)
for line in sys.stdin:
a,b = map(int, line.strip().split(','))
l[a-1], l[b-1] = l[b-1], l[a-1]
for x in l:
print x
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,278
|
s064140726
|
p00011
|
u506132575
|
1416115425
|
Python
|
Python
|
py
|
Accepted
| 20
|
4204
| 236
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
num_v = input()
num_h = input()
lis = range(num_v+1)
for s in sys.stdin:
d = map(int , s.split(",") )
lis[d[0]], lis[d[1]] = lis[d[1]], lis[d[0]]
for e in lis[1:]:
print e
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,279
|
s813196864
|
p00011
|
u342537066
|
1420705243
|
Python
|
Python3
|
py
|
Accepted
| 40
|
6720
| 219
|
w=int(input())
n=int(input())
lis=[i+1 for i in range(w)]
for _ in range(n):
a,b=map(int,input().split(","))
a-=1
b-=1
x=lis[a]
lis[a]=lis[b]
lis[b]=x
for i in range(w):
print(lis[i])
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,280
|
s334682831
|
p00011
|
u567380442
|
1422616474
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6724
| 252
|
import sys
f = sys.stdin
w = int(f.readline())
lots = [i + 1for i in range(w)]
n = int(f.readline())
for _ in range(n):
a, b = map(int , f.readline().split(','))
lots[a - 1], lots[b - 1] = lots[b - 1], lots[a - 1]
for i in lots:
print(i)
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,281
|
s289426333
|
p00011
|
u879226672
|
1423675636
|
Python
|
Python
|
py
|
Accepted
| 10
|
4220
| 330
|
while True:
try:
w = int(raw_input())
n = int(raw_input())
ans = [j for j in range(1,w+1)]
for k in range(n):
a,b = map(int,(raw_input().split(",")))
ans[a-1],ans[b-1] = ans[b-1],ans[a-1]
for item in ans:
print item
except EOFError:
break
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,282
|
s715890618
|
p00011
|
u744114948
|
1425202024
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6720
| 295
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright : @Huki_Hara
# Created : 2015-03-01
s=[]
W=int(input())
n=int(input())
for i in range(W):
s.append(i+1)
for _ in range(n):
a , b = map(int, input().split(","))
s[a-1], s[b-1] = s[b-1], s[a-1]
for i in s:
print(i)
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,283
|
s049657401
|
p00011
|
u744114948
|
1425202265
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6720
| 178
|
s = [i + 1 for i in range(int(input()))]
n = int(input())
for _ in range(n):
a , b = map(int, input().split(","))
s[a-1], s[b-1] = s[b-1], s[a-1]
for i in s:
print(i)
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,284
|
s238303604
|
p00011
|
u540744789
|
1425660999
|
Python
|
Python
|
py
|
Accepted
| 10
|
4212
| 208
|
w=int(raw_input())
number = range(1,w+1)
for i in xrange(input()):
a,b=map(int,raw_input().split(","))
tmp=number[a-1]
number[a-1]=number[b-1]
number[b-1]=tmp
print '\n'.join(map(str,number))
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,285
|
s057086523
|
p00011
|
u009961299
|
1431069745
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6720
| 269
|
# -*- coding: utf-8 -*-
w = int ( input ( ) )
n = int ( input ( ) )
lis = list ( range ( 1, w + 1 ) )
for i in range ( n ):
( a, b ) = map ( int, input ( ).split ( "," ) )
( lis[ a - 1 ], lis[ b - 1 ] ) = ( lis[ b - 1 ], lis[ a - 1 ] )
for x in lis:
print ( x )
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,286
|
s388861957
|
p00011
|
u067299340
|
1432874527
|
Python
|
Python
|
py
|
Accepted
| 10
|
4208
| 145
|
l=[i+1 for i in range(input())]
for a,b in[map(int,raw_input().split(","))for i in range(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,287
|
s476977566
|
p00011
|
u067299340
|
1432874601
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 134
|
l=range(1,input()+1)
for a,b in[map(int,raw_input().split(","))for i in range(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,288
|
s551812272
|
p00011
|
u067299340
|
1432874712
|
Python
|
Python
|
py
|
Accepted
| 20
|
4204
| 134
|
l=range(1,input()+1)
for a,b in[map(int,raw_input().split(","))for i in range(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,289
|
s909284868
|
p00011
|
u067299340
|
1432874770
|
Python
|
Python
|
py
|
Accepted
| 20
|
4200
| 135
|
l=range(1,input()+1)
for a,b in[map(int,raw_input().split(","))for i in xrange(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,290
|
s878015530
|
p00011
|
u067299340
|
1432874836
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 134
|
l=range(1,input()+1)
for a,b in[map(int,raw_input().split(","))for i in range(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,291
|
s784448983
|
p00011
|
u067299340
|
1432874955
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 141
|
l=range(1,input()+1)
for x in[raw_input().split(",")for i in range(input())]:
a,b=map(int,x)
l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,292
|
s531529181
|
p00011
|
u067299340
|
1432874978
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 134
|
l=range(1,input()+1)
for a,b in[map(int,raw_input().split(","))for i in range(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,293
|
s563667379
|
p00011
|
u379956761
|
1434727827
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6784
| 333
|
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
w = int(input())
n = int(input())
s = []
for _ in range(n):
x = input().split(',')
s.append((int(x[0]), int(x[1])))
result = [i for i in range(1, w+1)]
for x, y in s:
result[x-1], result[y-1] = result[y-1], result[x-1]
for x in result:
print(x)
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,294
|
s179096825
|
p00011
|
u749493116
|
1436406358
|
Python
|
Python
|
py
|
Accepted
| 10
|
4232
| 352
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n = input()
m = input()
line = []
for i in range(0, n):
line.append(i)
for i in range(0, m):
change = map(int, raw_input().split(','))
change[0] -= 1
change[1] -= 1
line[change[0]], line[change[1]] = line[change[1]], line[change[0]]
for i in range(0, n):
print line[i] + 1
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,295
|
s869094245
|
p00011
|
u873482706
|
1437290751
|
Python
|
Python
|
py
|
Accepted
| 10
|
4212
| 206
|
ans = [i+1 for i in range(int(raw_input()))]
for i in range(int(raw_input())):
a, b = map(int, raw_input().split(','))
ans[b-1], ans[a-1] = ans[a-1], ans[b-1]
else:
for a in ans:
print a
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,296
|
s142371054
|
p00011
|
u883062308
|
1438517996
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6720
| 254
|
w = int(input())
n = int(input())
nums = list(range(1, w + 1))
for i in range(n):
ab = input().split(",")
a = int(ab[0]) - 1
b = int(ab[1]) - 1
_a = nums[a]
nums[a] = nums[b]
nums[b] = _a
print("\n".join([str(n) for n in nums]))
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,297
|
s415285912
|
p00011
|
u722431421
|
1439560708
|
Python
|
Python
|
py
|
Accepted
| 20
|
4212
| 326
|
# coding: utf-8
#Problem Name: Drawing Lots
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp
w = int(raw_input())
n = int(raw_input())
change = [0 for _ in xrange(n)]
for i in xrange(n):
change[i] = eval(raw_input())
List = range(1,w+1)
for i,j in change:
List[i-1],List[j-1] = List[j-1],List[i-1]
for i in List:
print i
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,298
|
s133164859
|
p00011
|
u271261336
|
1442977081
|
Python
|
Python
|
py
|
Accepted
| 10
|
6324
| 209
|
w=int(raw_input())
number = range(1,w+1)
for i in xrange(input()):
a,b=map(int,raw_input().split(","))
tmp=number[a-1]
number[a-1]=number[b-1]
number[b-1]=tmp
print '\n'.join(map(str,number))
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,299
|
s273769318
|
p00011
|
u140201022
|
1443016480
|
Python
|
Python
|
py
|
Accepted
| 10
|
6244
| 171
|
w=int(raw_input())
l=range(w+1)
n=int(raw_input())
for i in range(n):
x,y=map(int,raw_input().split(','))
l[x],l[y]=l[y],l[x]
for i in range(1,w+1):
print l[i]
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,300
|
s131693188
|
p00011
|
u071010747
|
1445228227
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7720
| 303
|
def main():
LIST=[]
for i in range(int(input())):
LIST.append(i+1)
for j in range(int(input())):
a,b=map(int,input().split(","))
LIST[a-1],LIST[b-1]=LIST[b-1],LIST[a-1]
for i in LIST:
print(str(i))
if __name__ == '__main__':
main()
|
p00011
|
<H1>Drawing Lots</H1>
<p>
Let's play Amidakuji.
</p>
<p>
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1">
</center>
<br>
<p>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.
</p>
<p>
Your task is to write a program which reads the number of vertical lines <var>w</var> and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., <var>w</var> are assigne to the vertical lines from left to right.
</p>
<H2>Input</H2>
<pre>
<var>w</var>
<var>n</var>
<var>a<sub>1</sub></var>,<var>b<sub>1</sub></var>
<var>a<sub>2</sub></var>,<var>b<sub>2</sub></var>
.
.
<var>a<sub>n</sub></var>,<var>b<sub>n</sub></var>
</pre>
<p>
<var>w</var> (<var>w</var> ≤ 30) is the number of vertical lines. <var>n</var> (<var>n</var> ≤ 30) is the number of horizontal lines. A pair of two integers <var>a<sub>i</sub></var> and <var>b<sub>i</sub></var> delimited by a comma represents the <var>i</var>-th horizontal line.
</p>
<H2>Output</H2>
<p>
The number which should be under the 1st (leftmost) vertical line<br>
The number which should be under the 2nd vertical line<br>
:<br>
The number which should be under the <var>w</var>-th vertical line<br>
</p>
<H2>Sample Input</H2>
<pre>
5
4
2,4
3,5
1,2
3,4
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
1
2
5
3
</pre>
<!--
<H2>Hint</H2>
<a href="IMAGE1/lots.gif">Try it.</a>
-->
|
5
4
2,4
3,5
1,2
3,4
|
4
1
2
5
3
| 5,301
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.