submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s412278712 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[int(i) for i in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s899926985 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[int(j) for j in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s115789405 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
(x1,y1,x2,y2,x3,y3)=[int(j) for j in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s226022657 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s416847749 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
p_x=(x1+x2+x3)/3.0
p_y=(y1+y2+y3)/3.0
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s325666559 | p00010 | Runtime Error | # -*- coding: utf-8 -*-
import sys
def length(a, b):
return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5
def solve_sim_equ(a, b, c, d, e, f):
'''
From Problem 0004.
This function solves following equation.
ax + by = c
dx + ey = f
'''
if a==0 and d==0:
if b==0 and e==0:
return 0., 0.
if b != 0:
return 0., c/b+0.
else:
return 0., f/e+0.
elif b==0 and e==0:
if a != 0:
return 0., d/a+0.
else:
return 0., a/d+0.
if b == 0:
a, d = d, a
b, e = e, b
c, f = f, c
g = e / b
x = (g*c - f) / (g*a - d)
y = (c - a*x) / b
return x+0., y+0.
def circumscribed_circle(x, y, z):
def get_equ_coef(p, q):
h_x = (p[0] + q[0]) / 2
h_y = (p[1] + q[1]) / 2
a = q[1] - p[1]
b = p[0] - q[0]
c = b * h_x - a * h_y
return b, -a, c
coef = get_equ_coef(x, y) + get_equ_coef(y, z)
center = solve_sim_equ(*coef)
r = length(center, x)
return center, r
def main():
N = int(input())
for i in range(N):
vs = [float(v) for v in input().split()]
a = (vs[0], vs[1])
b = (vs[2], vs[3])
c = (vs[4], vs[5])
center, r = circumscribed_circle2(a, b, c)
print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r))
if __name__ == '__main__':
main() | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s110186981 | p00010 | Runtime Error | import math
deta=[float(i) for i in input().split()]
h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)
h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)
h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)
sub=(h1+h2+h3)/2
s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))
sum=((h1*h2*h3)/s)/4
a=2*deta[2]-2*deta[0]
b=2*deta[3]-2*deta[1]
c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))
d=2*deta[4]-2*deta[2]
e=2*deta[5]-2*deta[3]
f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))
x=(e*c-b*f)/(a*e-b*d)
y=(a*f-c*d)/(a*e-b*d)
print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,sum)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s024682548 | p00010 | Runtime Error | from math import sqrt
n=input()
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
A1=2*(x2-x1)
B1=2*(y2-y1)
C1=x2**2+y2**2-x1**2-y1**2
x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
y=((A1*C2)-(A2*C1))/((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)
p=(a+b+c)/2
S=sqrt(p*(p-a)*(p-b)*(p-c))
R=a*b*c/4/S
print"%.3f %.3f %.3f"%(x,y,R) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s742648167 | p00010 | Runtime Error | from math import sqrt
n=input()
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
A1=2*(x2-x1)
B1=2*(y2-y1)
C1=x2**2+y2**2-x1**2-y1**2
x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
y=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s424874268 | p00010 | Runtime Error | from math import sqrt
n=input()
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
A1=2*(x2-x1)
B1=2*(y2-y1)
C1=x2**2+y2**2-x1**2-y1**2
A2=2*(x3-x2)
B2=2*(y3-y2)
C2=x3**2+y3**2-x2**2-y2**2 | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s372109148 | p00010 | Runtime Error | import fractions
def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
print(cx1, cy1, z1, cx2, cy2, z2)
gcd = fractions.gcd(cx1, cx2)
r1, r2 = cx2 // gcd, cx1 // gcd
dcy = r1 * cy1 - r2 * cy2
dz = r1 * z1 - r2 * z2
y = dz / dcy
x = (z1 - cy1 * y) / cx1
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (x, y, r))) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s765675391 | p00010 | Runtime Error | import fractions
def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
gcd = fractions.gcd(cx1, cx2)
r1, r2 = cx2 // gcd, cx1 // gcd
dcy = r1 * cy1 - r2 * cy2
dz = r1 * z1 - r2 * z2
y = dz / dcy
x = (z1 - cy1 * y) / cx1
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (x, y, r))) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s066672060 | p00010 | Runtime Error | from math import sqrt
for _ in range(int(input())) :
x1, y1, x2, y2, x3, y3 = [float(temp) for temp in input().split()]
a = [x1, y1, (x1 ** 2) + (y1 ** 2)]
b = [x2, y2, (x2 ** 2) + (y2 ** 2)]
c = [x3, y3, (x3 ** 2) + (y3 ** 2)]
a1 = [(b[0] - a[0]), (b[1] - a[1]), (b[2] - a[2])]
b1 = [(c[0] - a[0]), (c[1] - a[1]), (c[2] - a[2])]
a1[1], a1[2] = (a1[1] / a1[0]), (a1[2] / a1[0])
b1[1], b1[2] = (b1[1] / b1[0]), (b1[2] / b1[0])
m = -(a1[2] - b1[2]) / (a1[1] - b1[1])
l = -(a1[1] * m + a1[2])
n = -((l * a[0]) + (m * a[1]) + a[2])
px = -l / 2
py = -m / 2
r = sqrt(((l / 2) ** 2)+((m / 2) ** 2)+n)
print('{:0.3f} {:0.3f} {:0.3f}'.format(px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s655692986 | p00010 | Runtime Error | # Aizu Problem 0010: Circumscribed Circle of a Triangle
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def circumscribed_circle(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 = .5 * abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y1 - y1))
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)
r = a * b * c / (4 * A)
return px, py, r
N = int(input())
for k in range(N):
x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()]
px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3)
print("%.3f %.3f %.3f" % (px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s842545166 | p00010 | Runtime Error | for _ in [0]*int(input()):
a,d,b,e,c,f=map(float,input().split())
z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s386945215 | p00010 | Runtime Error | for i in range(n):
x1,y1,x2,y2,x3,y3=map(float, input().split())
x4,y4=0.5*(x2+x3), 0.5*(y2+y3)
xg,yg=2/3*(2*x1+x4), 2/3*(2*y1+y4)
xo,yo=(x1+x2+x3)/3, (y1+y2+y3)/3
r=((xo-x1)**2+(yo-y1)**2)**0.5
print(xg, yg, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s456535820 | p00010 | Runtime Error | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
print(points_list)
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1 / a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s815708549 | p00010 | Runtime Error | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
print(points_list)
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s856122872 | p00010 | Runtime Error | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s024542183 | p00010 | Runtime Error | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
if points_list[2][1] == points_list[0][1]:
px = (points_list[0][0] + points_list[2][0])/2
else:
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
if points_list[2][1] == points_list[0][1]:
px = (points_list[0][0]+points_list[2][0])/2
else:
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s209276934 | p00010 | Runtime Error | for _ in[0]*int(input()):
a,b,c,d,e,f=map(int,input().split())
x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
y=((a*a+b*b)*(c-d)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
print(f"{x:.4} {y:.4} {(x*x+y*y)**.5:.4}")
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s645411869 | p00010 | Runtime Error | for _ in[0]*int(input()):
a,b,c,d,e,f=map(float,input().split())
x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
print('.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s493329395 | p00010 | Runtime Error | import math
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('%.3f %.3f %.3f'%(x,y,math.hypot(x-a,y-b)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s041780846 | p00010 | Runtime Error | from math import sqrt
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(int,input().split())
x4=((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
y4=((x1-x3)*(x1**2-x2**2+y1**2-x1**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
r=sqrt((x1-x4)**2+(y1-y4)**2);
print("{:.3f} {:.3f} {:.3f}".format(x4,y4,r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s439207147 | p00010 | Runtime Error | from math import hypot
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(int,input().split())
x4=((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
y4=((x1-x3)*(x1**2-x2**2+y1**2-x1**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
r=hypot(x1-x4,y1-y4)
print("{:.3f} {:.3f} {:.3f}".format(x4,y4,r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s787344628 | p00010 | Runtime Error | import math
while True:
t=input()
if t == "":break
l=t.split()
px=sum(l[0::2])/3
py=sum(l[1::2])/3
r=math.sqrt((l[0]-px)**2+(l[1]-py)**2)
print("{0} {1} {2}".format([round(i,3) for i in[px,py,r]]))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s390865087 | p00010 | Runtime Error | import math
input()
while True:
t=input()
if t == "":break
l=[float(i) for i in t.split()]
px=sum(l[0::2])/3
py=sum(l[1::2])/3
r=math.sqrt((l[0]-px)**2+(l[1]-py)**2)
print("{0} {1} {2}".format([round(i,3) for i in[px,py,r]]))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s085524056 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
t1=x1*(x2+x3-x1)+y1*(y2+y3-y1)
t2=x2*(x1+x3-x2)+y2*(y1+y3-y2)
t3=x3*(x1+x2-x3)+y3*(y1+y2-y3)
px=(t1*x1+t2*x2+t3*x3)/(t1+t2+t3)
py=(t1*y1+t2*y2+t3*y3)/(t1+t2+t3)
r=math.hypot(px-x1,py-y1)
print("{0} {1} {2}".format(round(px,3),round(py,3),round(r,3)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s435174264 | p00010 | Runtime Error | import math
n=int(raw_input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in raw_input().split()]
t1=x1*(x2+x3-x1)+y1*(y2+y3-y1)
t2=x2*(x1+x3-x2)+y2*(y1+y3-y2)
t3=x3*(x1+x2-x3)+y3*(y1+y2-y3)
px=(t1*x1+t2*x2+t3*x3)/(t1+t2+t3)
py=(t1*y1+t2*y2+t3*y3)/(t1+t2+t3)
r=math.hypot(px-x1,py-y1)
print("{0} {1} {2}".format(round(px,3),round(py,3),round(r,3)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s027469812 | p00010 | Runtime Error | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
t1=x1*(x2+x3-x1)+y1*(y2+y3-y1)
t2=x2*(x1+x3-x2)+y2*(y1+y3-y2)
t3=x3*(x1+x2-x3)+y3*(y1+y2-y3)
px=(t1*x1+t2*x2+t3*x3)/(t1+t2+t3)
py=(t1*y1+t2*y2+t3*y3)/(t1+t2+t3)
r=math.hypot(px-x1,py-y1)
print("%f %f %f"%(round(px,3),round(py,3),round(r,3)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s989146239 | p00010 | Runtime Error | 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}')
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s665551975 | p00010 | Runtime Error | from numpy import *
from numpy.linalg import solve
N=input()
a1,b1,a2,b2,a3,b3=map(float, raw_input().split())
a=array([[ 2*(a2-a1),2*(b2-b1) ],[ 2*(a3-a1),2*(b3-b1) ]])
b=array([a2**2+b2**2-a1**2-b1**2,a3**2+b3**2-a1**2-b1**2])
x=solve(a, b)
print x[0],x[1], round( ( (a1-x[0])**2+(b1-x[1])**2 )**0.5 , 3)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s631077055 | p00010 | Runtime Error | # -*- coding: utf-8 -*-
from math import sqrt
import numpy as np
# n = int(input())
# tmp = input().split(' ')
tmp = '0.0 0.0 2.0 0.0 2.0 2.0'.split(' ')
# tmp = '0.0 3.0 -1.0 0.0 -3.0 4.0'.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)))
B = np.array((((-(a[0]**2 + a[1]**2))),
((-(b[0]**2 + b[1]**2))),
((-(c[0]**2 + c[1]**2)))))
tmp = np.dot(np.linalg.inv(A), B)
#tmp = [-6, 10, 18]
x = -tmp[0]/2
y = -tmp[1]/2
r = sqrt((tmp[0]**2 + tmp[1]**2 - 4*tmp[2])/4)
print('{:.3} {:.3} {:.3}'.format(x, y, r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s101671470 | p00010 | Runtime Error | import math
for val in xrange(0,input()):
x = map(float,raw_input().split(' '))
a = 2*(x[0]-x[2])
b = 2*(x[1]-x[3])
c = (x[1]**2-x[2]**2)-(x[1]**2-x[3]**2)
d = 2*(x[0]-x[4])
e = 2*(x[1]-x[5])
f = (x[1]**2-x[4]**2)-(x[1]**2-x[5]**2)
p = round((c*e-b*f)/(a*e-b*d),4)
q = round((a*f-c*d)/(a*e-b*d),4)
X = '%.3f' % p
Y = '%.3f' % q
if str(x) == '-0.000': X = '%.3f' % 0.000
if str(y) == '-0.000': Y = '%.3f' % 0.000
r = (x[0]-X)**2+(x[1]-Y)**2
r = math.sqrt(r)
r = math.fabs(r)
print X,Y,r | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s255340438 | p00010 | Runtime Error | import math
for val in xrange(0,input()):
x = map(float,raw_input().split(' '))
a = 2*(x[0]-x[2])
b = 2*(x[1]-x[3])
c = (x[1]**2-x[2]**2)-(x[1]**2-x[3]**2)
d = 2*(x[0]-x[4])
e = 2*(x[1]-x[5])
f = (x[1]**2-x[4]**2)-(x[1]**2-x[5]**2)
p = round((c*e-b*f)/(a*e-b*d),4)
q = round((a*f-c*d)/(a*e-b*d),4)
X = '%.3f' % p
Y = '%.3f' % q
if str(x) == '-0.000': X = '%.3f' % 0.000
if str(y) == '-0.000': Y = '%.3f' % 0.000
r = (x[0]-X)**2+(x[1]-Y)**2
r = math.sqrt(r)
r = math.fabs(r)
print X,Y,r | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s395566522 | p00010 | Runtime Error | import math
for val in xrange(0,input()):
x = map(float,raw_input().split(' '))
a = 2*(x[0]-x[2])
b = 2*(x[1]-x[3])
c = (x[1]**2-x[2]**2)-(x[1]**2-x[3]**2)
d = 2*(x[0]-x[4])
e = 2*(x[1]-x[5])
f = (x[1]**2-x[4]**2)-(x[1]**2-x[5]**2)
p = round((c*e-b*f)/(a*e-b*d),4)
q = round((a*f-c*d)/(a*e-b*d),4)
X = '%.3f' % p
Y = '%.3f' % q
if str(X) == '-0.000': X = '%.3f' % 0.000
if str(Y) == '-0.000': Y = '%.3f' % 0.000
r = (x[0]-X)**2+(x[1]-Y)**2
r = math.sqrt(r)
r = math.fabs(r)
print X,Y,r | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s999806676 | p00010 | Runtime Error | import math
class Triangle:
def __init__(self, x1, y1, x2, y2, x3, y3):
self.x1 = x1
self.x2 = x2
self.x3 = x3
self.y1 = y1
self.y2 = y2
self.y3 = y3
self.c = math.hypot(x1 - x2, y1 - y2)
self.a = math.hypot(x2 - x3, y2 - y3)
self.b = math.hypot(x3 - x1, y3 - y1)
print self.a
print self.b
print self.c
self.degreeA = math.acos((self.b ** 2 + self.c ** 2 - self.a ** 2) / (2 * self.b * self.c))
self.degreeB = math.acos((self.c ** 2 + self.a ** 2 - self.b ** 2) / (2 * self.c * self.a))
self.degreeC = math.acos((self.a ** 2 + self.b ** 2 - self.c ** 2) / (2 * self.a * self.b))
def circumscribedCircleRadius(self):
return self.a / math.sin(self.degreeA) / 2.0
def circumscribedCircleX(self):
A = math.sin(2.0 * self.degreeA)
B = math.sin(2.0 * self.degreeB)
C = math.sin(2.0 * self.degreeC)
return (self.x1 * A + self.x2 * B + self.x3 * C) / (A + B + C)
n = input()
for t in range(n):
data = map(float, raw_input().split())
t = Triangle(data)
print "%.3f %.3f" % (round(t.circumscribedCircleRadius(),4), round(t.circumscribedCircleRadius(), 4)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s546845271 | p00010 | Runtime Error | import math
a = int(raw_input())
while a > 0:
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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s123411670 | p00010 | Runtime Error | 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
def f003():
n=input()
A=[]
for i in range(n):
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
return x0,y0,r
x0,y0,r = f003()
print "%.3f %.3f %.3f" %(x0, y0, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s902788836 | p00010 | Runtime Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s764393994 | p00010 | Runtime Error | #include <stdio.h>
#include <math.h>
int main(void){
int n;
double x1,y1,x2,y2,x3,y3,a,b,c,s,ss,sina,r,px,py;
scanf("%d",&n);
while (n--){
scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
a = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
b = sqrt(pow(x1-x3,2)+pow(y1-y3,2));
c = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
s = (a+b+c)/2;
ss = 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/pow(ss,2);
py = (a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/pow(ss,2);
printf("%.3f %.3f %.3f",px, py, r);
}
} | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s961372471 | p00010 | Runtime Error | #include <stdio.h>
#include <math.h>
int main(void){
int n;
double x1,y1,x2,y2,x3,y3,a,b,c,s,ss,sina,r,px,py;
scanf("%d",&n);
while (n--){
scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
a = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
b = sqrt(pow(x1-x3,2)+pow(y1-y3,2));
c = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
s = (a+b+c)/2;
ss = 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/pow(ss,2);
py = (a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/pow(ss,2);
printf("%.3f %.3f %.3f\n",px, py, r);
}
} | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s917058945 | p00010 | Runtime Error | #include <stdio.h>
#include <math.h>
int main(void){
int n;
double x1,y1,x2,y2,x3,y3,a,b,c,s,ss,sina,r,px,py;
scanf("%d",&n);
while (n--){
scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
a = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
b = sqrt(pow(x1-x3,2)+pow(y1-y3,2));
c = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
s = (a+b+c)/2;
ss = 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/pow(ss,2);
py = (a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/pow(ss,2);
printf("%.3f %.3f %.3f\n", px, py, r);
}
return 0;
} | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s469345396 | p00010 | WA: Presentation Error | import math
n = int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float,input().split())
a1,b1,c1 = 2*(x2-x1),2*(y2-y1), (x1**2 - x2 **2 + y1 ** 2 - y2 ** 2)
a2,b2,c2 = 2*(x3-x1), 2*(y3-y1), (x1**2 - x3 **2 + y1 ** 2 - y3 ** 2)
p1 = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
p2 = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
r = math.hypot(x1-p1, y1-p2)
print("%03.3f %03.3f %03.3f " %(p1,p2,r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s834176394 | p00010 | WA: Presentation Error | n = int(input())
datasets = [0]*n
#datasets[k] == [x1k,y1k,x2k,y2k,x3k,y3k]
for i in range(0,n):
datasets[i] = list(map(float,input().split()))
for data in datasets:
x=((data[0]+data[2])*(data[0]-data[2])*(data[1]-data[5])+(data[1]+data[3])*(data[1]-data[3])*(data[1]-data[5])-(data[0]+data[4])*(data[0]-data[4])*(data[1]-data[3])-(data[1]+data[5])*(data[1]-data[5])*(data[1]-data[3]))/(2*((data[0]-data[2])*(data[1]-data[5])-(data[0]-data[4])*(data[1]-data[3])))
y=((data[1]+data[3])*(data[1]-data[3])*(data[0]-data[4])+(data[0]+data[2])*(data[0]-data[2])*(data[0]-data[4])-(data[1]+data[5])*(data[1]-data[5])*(data[0]-data[2])-(data[0]+data[4])*(data[0]-data[4])*(data[0]-data[2]))/(2*((data[1]-data[3])*(data[0]-data[4])-(data[1]-data[5])*(data[0]-data[2])))
r=((x-data[0])**2+(y-data[1])**2)**(1/2)
print("{0:.3f} {1:.3f} {2:.3f}\n".format(x,y,r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s032336142 | p00010 | WA: Presentation Error | n = int(input())
datasets = [0]*n
#datasets[k] == [x1k,y1k,x2k,y2k,x3k,y3k]
for i in range(0,n):
datasets[i] = list(map(float,input().split()))
for data in datasets:
x1p2=(data[0]+data[2])
x1m2=(data[0]-data[2])
x1p3=(data[0]+data[4])
x1m3=(data[0]-data[4])
y1p2=(data[1]+data[3])
y1m2=(data[1]-data[3])
y1p3=(data[1]+data[5])
y1m3=(data[1]-data[5])
x=(x1p2*x1m2*y1m3+y1p2*y1m2*y1m3-x1p3*x1m3*y1m2-y1p3*y1m3*y1m2)/(2*(x1m2*y1m3-x1m3*y1m2))
y=(y1p2*y1m2*x1m3+x1p2*x1m2*x1m3-y1p3*y1m3*x1m2-x1p3*x1m3*x1m2)/(2*(y1m2*x1m3-y1m3*x1m2))
r=((x-data[0])**2+(y-data[1])**2)**(1/2)
print("{0:.3f} {1:.3f} {2:.3f}\n".format(x,y,r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s332429418 | p00010 | WA: Presentation Error | n = int(input())
datasets = [0]*n
for i in range(0,n):
datasets[i] = list(map(float,input().split()))
for data in datasets:
x1p2=(data[0]+data[2])
x1m2=(data[0]-data[2])
x1p3=(data[0]+data[4])
x1m3=(data[0]-data[4])
y1p2=(data[1]+data[3])
y1m2=(data[1]-data[3])
y1p3=(data[1]+data[5])
y1m3=(data[1]-data[5])
x=(x1p2*x1m2*y1m3+y1p2*y1m2*y1m3-x1p3*x1m3*y1m2-y1p3*y1m3*y1m2)/(2*(x1m2*y1m3-x1m3*y1m2))
y=(y1p2*y1m2*x1m3+x1p2*x1m2*x1m3-y1p3*y1m3*x1m2-x1p3*x1m3*x1m2)/(2*(y1m2*x1m3-y1m3*x1m2))
r=((x-data[0])**2+(y-data[1])**2)**(1/2)
print("{0:.3f} {1:.3f} {2:.3f}\n".format(x,y,r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s254675929 | p00010 | WA: Presentation Error | n = int(input())
datasets = [0]*n
#datasets[k] == [x1k,y1k,x2k,y2k,x3k,y3k]
for i in range(0,n):
datasets[i] = list(map(float,input().split()))
for data in datasets:
x1p2=(data[0]+data[2])
x1m2=(data[0]-data[2])
x1p3=(data[0]+data[4])
x1m3=(data[0]-data[4])
y1p2=(data[1]+data[3])
y1m2=(data[1]-data[3])
y1p3=(data[1]+data[5])
y1m3=(data[1]-data[5])
x=(x1p2*x1m2*y1m3+y1p2*y1m2*y1m3-x1p3*x1m3*y1m2-y1p3*y1m3*y1m2)/(2*(x1m2*y1m3-x1m3*y1m2))
y=(y1p2*y1m2*x1m3+x1p2*x1m2*x1m3-y1p3*y1m3*x1m2-x1p3*x1m3*x1m2)/(2*(y1m2*x1m3-y1m3*x1m2))
r=((x-data[0])**2+(y-data[1])**2)**(1/2)
if x == 0.000:
x=0
if y == 0.000:
y=0
print("{0:.3f} {1:.3f} {2:.3f}\n".format(x,y,r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s779651012 | p00010 | WA: Presentation Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<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>
|
s231065969 | p00011 | Wrong Answer | #!/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)]
print(len(result))
for x, y in s:
result[x-1], result[y-1] = result[y-1], result[x-1]
for x in result:
print(x) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s776187794 | p00011 | Wrong Answer | 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(i) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s885726210 | p00011 | Wrong Answer | w=int(input())
n=int(input())
A=[int(i+1) for i in range(w)]
for i in range(n):
x,y=map(int,input().split(','))
A[x-1],A[y-1]=A[y-1],A[x-1]
print(A) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s496501582 | p00011 | Wrong Answer | a=int(input())
b=int(input())
c=range(1,b+1)
for i in range(a):
d=str(raw_input())
c[int(d[0])],c[int(d[-1])]=c[int(d[-1])],c[int(d[0])]
for i in c:print(i) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s614365799 | p00011 | Wrong Answer | w = int(input())
n = int(input())
Ami = []
Num = []
for i in range(n):
Ami.append(list(map(int,input().split(","))))
print(Ami)
for i in range(1,w+1):
pos = i
for j in range(n):
if pos == Ami[j][0]:
pos = Ami[j][1]
elif pos == Ami[j][1]:
pos = Ami[j][0]
Num.append([pos,i])
Num = sorted(Num)
for k in range(0,w):
print(Num[k][1]) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s774941960 | p00011 | Wrong Answer | def get_another_num(data, me):
if data[0] == me:
return data[1]
else:
return data[0]
if __name__ == '__main__':
# ??????????????\???
v_lines = 5
h_lines = 4
data = [(2, 4), (3, 5), (1, 2), (3, 4)]
# ????????????????????????
results = [0] * (v_lines + 1)
for i in range(1, v_lines + 1):
me = i
for amida in data:
if me in amida:
me = get_another_num(amida, me)
results[me] = i
# ???????????¨???
for i in range(1, v_lines + 1):
print(results[i]) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s612459602 | p00011 | Wrong Answer | w = int(input())
n = int(input())
array = [[i for i in input().split(",")]for i in range(n)]
a = -1
b = 1
c = False
d = [0 for i in range(w)]
for i in range(w):
for i2 in range(n):
if (i+1 == int(array[i2][0]) or i+1 == int(array[i2][1])) and a == -1:
a = i2
if i+1 == int(array[i2][0]):
b = int(array[i2][1])
else:
b = int(array[i2][0])
c = True
if c and a < i2 and (b == int(array[i2][0]) or b == int(array[i2][1])):
a = i2
if b == int(array[i2][0]):
b = int(array[i2][1])
else:
b = int(array[i2][0])
d[b-1] = i+1
a = -1
b = i+1
c = False
for i in range(w):
print(d[i]) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s342009644 | p00011 | Wrong Answer | import sys
n = int(sys.stdin.readline().rstrip())
m = int(sys.stdin.readline().rstrip())
l = []
for i in range(m):
l.append(list(map(int, sys.stdin.readline().rstrip().split(','))))
print(l)
for i in range(n):
cur = i+1
for d in l[::-1]:
if cur in d:
cur = d[0] if cur == d[1] else d[1]
print(cur) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s063333640 | p00011 | Wrong Answer | user = input()
w = int(user)
user = input()
n = int(user)
a = []
b = []
now = 0
for i in range(n):
user = input()
users = user.split(",")
a.append(int(users[0]))
b.append(int(users[1]))
print(a)
print(b)
for j in range(1, w+1):
now = j
for k in reversed(range(n)):
if now == a[k]:
now = b[k]
elif now == b[k]:
now = a[k]
print(now) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s971152687 | p00011 | Wrong Answer | stick = [i for i in range(1, int(input()) + 1)]
net = int(input())
for _ in range(net):
a, b = list(map(int, input().split(",")))
stick[a - 1], stick[b - 1] = stick[b - 1], stick[a - 1]
print(stick)
print("\n".join(map(str, stick))) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s608510230 | p00011 | Wrong Answer | a=list(range(int(input())+1))
for _ in[0]*int(input()):
s,t=map(int,input().split(','))
a[s],a[t]=a[t],a[s]
for s in a:print(s+1)
| 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s191330965 | p00011 | Wrong Answer | a=list(range(int(input())+1))
for _ in[0]*int(input()):
s,t=map(int,input().split(','))
a[s],a[t]=a[t],a[s]
for s in a:
if s:print(s+1)
| 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s708276448 | p00011 | Wrong Answer | import pprint
amida = []
def main():
num_vlines = int(raw_input());
num_wlines = int(raw_input());
init_amida(num_vlines)
count = 0;
while count < num_wlines :
ab = raw_input().strip().split(',')
# print "--- input keys ---"
# pprint.pprint(ab)
transposition(int(ab[0]), int(ab[1]))
# print "--- dump amida ---"
# print amida.items()
count += 1
for i in range(1, num_vlines + 1):
print amida[i],
def init_amida(num_vlines):
for i in range(num_vlines + 1):
amida.append(i)
# pprint.pprint(amida)
def transposition(a, b):
tmp = amida[a]
amida[a] = amida[b]
amida[b] = tmp
main() | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s092918158 | p00011 | Wrong Answer | amida = []
def main():
num_vlines = int(raw_input());
num_wlines = int(raw_input());
init_amida(num_vlines)
count = 0;
while count < num_wlines :
ab = raw_input().strip().split(',')
# print "--- input keys ---"
# pprint.pprint(ab)
transposition(int(ab[0]), int(ab[1]))
# print "--- dump amida ---"
# print amida.items()
count += 1
for i in range(1, num_vlines + 1):
print amida[i],
def init_amida(num_vlines):
for i in range(num_vlines + 1):
amida.append(i)
# pprint.pprint(amida)
def transposition(a, b):
tmp = amida[a]
amida[a] = amida[b]
amida[b] = tmp
main() | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s525541363 | p00011 | Wrong Answer | import sys
def main():
tate = int(raw_input())
result = []
for i in range(1, tate+1):
result.append(i)
print result
yoko = int(raw_input())
for line in sys.stdin.readlines():
x1, x2 = map(int, line.split(","))
x1 -= 1
x2 -= 1
temp = result[x2]
result[x2] = result[x1]
result[x1] = temp
for num in result:
print num
if __name__ == '__main__':
main() | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s536378600 | p00011 | Wrong Answer | W = range(input()+2)
for i in range(input()):
a, b = map(int,raw_input().split(","))
W[a], W[b] = W[b], W[a]
for e in W[1:]:
print e | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s980703368 | p00011 | Wrong Answer | w = int(raw_input())
bars = []
ans = [0 for i in range(w)]
for i in range(int(raw_input())):
bars.append(map(int, raw_input().split(',')))
print bars
for i, j in zip(range(1, w+1),range(0,w)):
for bar in bars:
if bar[0] == i:
i = bar[1]
elif bar[1] == i:
i = bar[0]
ans[i-1] = j+1
for s in ans:
print s | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s665570502 | p00011 | Accepted | 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()
| 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s003690790 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s064140726 | p00011 | Accepted | #!/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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s813196864 | p00011 | Accepted | 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])
| 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s334682831 | p00011 | Accepted | 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) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s289426333 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s715890618 | p00011 | Accepted | #!/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) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s049657401 | p00011 | Accepted | 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) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s238303604 | p00011 | Accepted | 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)) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s057086523 | p00011 | Accepted | # -*- 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 ) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s388861957 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s476977566 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s909284868 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s784448983 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s563667379 | p00011 | Accepted | #!/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) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s179096825 | p00011 | Accepted | #!/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
| 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s869094245 | p00011 | Accepted | 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s142371054 | p00011 | Accepted | 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])) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s415285912 | p00011 | Accepted | # 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 | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s133164859 | p00011 | Accepted | 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)) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s273769318 | p00011 | Accepted | 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] | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s131693188 | p00011 | Accepted | 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() | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s243793687 | p00011 | Accepted | w = int(input())
n = int(input())
lines = []
for i in range(n):
a, b = map(int, input().split(","))
lines.append([a, b])
lines = list(reversed(lines))
for j in range(1, w + 1):
for line in lines:
if line[0] == j:
j = line[1]
elif line[1] == j:
j = line[0]
print(j) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s379189261 | p00011 | Accepted | w = int(input()) + 1
l = [i for i in range(w)]
n = int(input())
for i in range(n):
a, b = map(int, input().split(","))
l[a], l[b] = l[b], l[a]
for i in range(1, w):
print(l[i]) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s192476986 | p00011 | Accepted | w = int(input())
n = int(input())
l = [i for i in range(1,w+1)]
while n > 0:
a,b = map(int,input().split(','))
l[a-1],l[b-1] = l[b-1],l[a-1]
n -= 1
for i in l:
print(i) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s273917313 | p00011 | Accepted | while True:
try:
n = int(raw_input())
ans = [i for i in range(n+1)]
m = int(raw_input())
for i in range(m):
a, b = map(int, raw_input().strip().split(','))
t = ans[a]
ans[a] = ans[b]
ans[b] = t
ans = ans[1:]
for x in ans:
print x
except EOFError:
break | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s600846072 | p00011 | Accepted | w=int(input())
n=int(input())
a=[]
for i in range(w):
a.append(i+1)
for i in range(n):
m, n= map(int,input().split(','))
temp=a[m-1]
a[m-1]=a[n-1]
a[n-1]=temp
for i in range(w):
print(a[i]) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s044914878 | p00011 | Accepted | import sys
lines = sys.stdin.readlines()
w = lines[0]
n = lines[1]
exchanges = lines[2:len(lines)]
ret = list(range(1,int(w)+1))
for line in exchanges:
line = line.split(",")
inp = []
for i in line:
inp.append(int(i))
ret[inp[0]-1],ret[inp[1]-1] = ret[inp[1]-1],ret[inp[0]-1]
for i in ret:
print (i) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s449982820 | p00011 | Accepted | w, n = int(input()), int(input())
l = list(range(w + 1))
for _ in range(n):
a, b = map(int, input().split(','))
l[a], l[b] = l[b], l[a]
print('\n'.join([str(i) for i in l[1:]])) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s110686993 | p00011 | Accepted | #! -*- coding:utf-8 -*-
def replace(num1,num2,nums):
tmp = nums[num1-1]
nums[num1-1]=nums[num2-1]
nums[num2-1]=tmp
w = input()
nums = [x+1 for x in xrange(w)]
n = input()
for x in xrange(n):
num1,num2 = map(int,raw_input().split(","))
replace(num1,num2,nums)
for num in nums:
print num | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s372827054 | p00011 | Accepted | while True:
try:
n = int(raw_input())
ans = [i for i in range(n+1)]
m = int(raw_input())
for i in range(m):
a, b = map(int, raw_input().strip().split(','))
t = ans[a]
ans[a] = ans[b]
ans[b] = t
ans = ans[1:]
for x in ans:
print x
except EOFError:
break | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s157896667 | p00011 | Accepted | w = int(input())
n = int(input())
l = [list(map(int, input().split(','))) for x in range(n)]
res = [0] * (w + 1)
for i in range(1, w + 1):
c = i
for a in l:
if a[0] == c:
c = a[1]
elif a[1] == c:
c = a[0]
res[c] = i
for r in res[1:]:
print(r) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s243647565 | p00011 | Accepted | w = int(input())
n = int(input())
l = list(reversed([list(map(int, input().split(','))) for x in range(n)]))
for i in range(1, w + 1):
c = i
for a in l:
if a[0] == c:
c = a[1]
elif a[1] == c:
c = a[0]
print(c) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
s254797223 | p00011 | Accepted | w=int(input())
n=int(input())
A=[int(i+1) for i in range(w)]
for i in range(n):
x,y=map(int,input().split(','))
A[x-1],A[y-1]=A[y-1],A[x-1]
for i in range(w):
print(A[i]) | 5
4
2,4
3,5
1,2
3,4
| 4
1
2
5
3
|
<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>
-->
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.