submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s501089072
p00011
Runtime Error
a=int(input()) b=int(input()) c=range(1,b+1) for i in range(a): d=str(raw_input()) c[int(d[0]-1)],c[int(d[-1]-1)]=c[int(d[-1]-1)],c[int(d[0]-1)] 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s510196485
p00011
Runtime Error
a=int(input()) b=int(input()) c=range(1,b+1) for i in range(a): d=str(raw_input()) d,e=int(d[0]-1),int(d[2]-1) c[d],c[e]=c[e],c[d) 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s950262392
p00011
Runtime Error
a=int(input()) b=int(input()) c=range(1,b+1) for i in range(a): d=str(raw_input()) d,e=int(d[0]-1),int(d[2]-1) c[d],c[e]=c[e],c[d]) 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s140300850
p00011
Runtime Error
a=int(input()) b=int(input()) c=range(1,b+1) for i in range(a): d,e=map(int,raw_input().split()) c[d],c[e]=c[e],c[d]) 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s000688486
p00011
Runtime Error
# -*- coding: utf-8 -*- def solve(w, n): l = [i for i in range(1, w+1)] for _ in range(n): a, b = map(int, input().split(',')) l[a], l[b] = l[b], l[a] print(*l, sep='\n') if __name__ == '__main__': w = int(input()) n = int(input()) solve(w, n)
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s383171804
p00011
Runtime Error
# -*- coding: utf-8 -*- def solve(): w = int(input()) n = int(input()) l = [i for i in range(1, w+1)] for _ in range(n): a, b = map(int, input().split(',')) l[a], l[b] = l[b], l[a] print(*l, sep='\n') solve()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s611347983
p00011
Runtime Error
def swap(a, b, x): if x <> a and x <> b: return x elif x == a: return b elif x == b: return a w = raw_input() n = raw_input() result = range(1, w+1) for i in range(n): a, b = map(lambda x: int(x), raw_input().split(',') result = [ swap(a, b, x) for x in result ] 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s729794414
p00011
Runtime Error
# -*- coding:utf-8 -*- import sys w = int(input()) n = int(input()) array = [] count = 0 for i in sys.stdin: array.append(i) count += 1 if count == n: break a, b = [0]*n, [0]*n for i in range(n): s = array[i] a[i], b[i] = s[0], s[2] a[i], b[i] = int(a[i]), int(b[i]) lines = [] k = 0 for i in range(w): lines.append(k) k += 1 for i in range(n): tmp1 = lines[a[i]-1] tmp2 = lines[b[i]-1] lines[a[i]-1] = tmp2 lines[b[i]-1] = tmp1 for i in range(len(lines)): print(lines[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s924826169
p00011
Runtime Error
# -*- coding:utf-8 -*- import sys w = int(input()) n = int(input()) array = [] count = 0 for i in sys.stdin: array.append(i) count += 1 if count == n: break a, b = [0]*n, [0]*n for i in range(n): s = array[i] a[i], b[i] = s[0], s[2] a[i], b[i] = int(a[i]), int(b[i]) lines = [] k = 0 for i in range(w): lines.append(k) k += 1 for i in range(n): tmp1 = lines[a[i]-1] tmp2 = lines[b[i]-1] lines[a[i]-1] = tmp2 lines[b[i]-1] = tmp1 for i in range(len(lines)): print(lines[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s425834142
p00011
Runtime Error
# -*- coding:utf-8 -*- import sys w = int(input()) n = int(input()) array = [] for i in range(n): array.append(input()) a, b = [0]*n, [0]*n for i in range(n): s = array[i] a[i], b[i] = s[0], s[1] a[i], b[i] = int(a[i]), int(b[i]) lines = [] k = 0 for i in range(w): lines.append(k) k += 1 for i in range(n): tmp1 = lines[a[i]-1] tmp2 = lines[b[i]-1] lines[a[i]-1] = tmp2 lines[b[i]-1] = tmp1 for i in range(len(lines)): print(lines[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s908973868
p00011
Runtime Error
# -*- coding:utf-8 -*- import sys w = int(input()) n = int(input()) array = [0]*n for i in range(n): array[i] = input() a, b = [0]*n, [0]*n for i in range(n): s = array[i] a[i], b[i] = s[0], s[1] a[i], b[i] = int(a[i]), int(b[i]) lines = [] k = 0 for i in range(w): lines.append(k) k += 1 for i in range(n): tmp1 = lines[a[i]-1] tmp2 = lines[b[i]-1] lines[a[i]-1] = tmp2 lines[b[i]-1] = tmp1 for i in range(len(lines)): print(lines[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s140888798
p00011
Runtime Error
# -*- coding:utf-8 -*- import sys w = int(input()) n = int(input()) array = [] for i in range(n): array.append(input()) a, b = [], [] for i in range(n): s = array[i] a.append(s[0]) b.append(s[1]) a[i], b[i] = int(a[i]), int(b[i]) lines = [] k = 0 for i in range(w): lines.append(k) k += 1 for i in range(n): tmp1 = lines[a[i]-1] tmp2 = lines[b[i]-1] lines[a[i]-1] = tmp2 lines[b[i]-1] = tmp1 for i in range(len(lines)): print(lines[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s476539102
p00011
Runtime Error
w = int(input()) n = int(input()) nums = list(range(w + 1)) for i in range(n): s = list(map(int, input().split(", "))) nums[s[0]], nums[s[1]] = nums[s[1]], nums[s[0]] for j in range(w): print(nums[j + 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s714849117
p00011
Runtime Error
w = int(input()) nums = list(range(w + 1)) for _ in range(int(input())): a, b = list(map(int, input().split(", "))) nums[a], nums[b] = nums[b], nums[a] for i in range(w): print(nums[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s945165706
p00011
Runtime Error
w = int(input()) nums = list(range(w + 1)) for _ in range(int(input())): a, b = map(int, input().split(", ")) nums[a], nums[b] = nums[b], nums[a] for x in nums[1:]: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s035673685
p00011
Runtime Error
w = int(input()) n = int(input()) nums = list(range(w + 1)) for _ in range(n): a, b = map(int, input().split(", ")) nums[a], nums[b] = nums[b], nums[a] for x in nums[1:]: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s183424483
p00011
Runtime Error
w = int(input()) n = int(input()) l = list(range(1,w+1)) for i in range(n): a,b = map(int,input().split(',')) a -= 1 b - = 1 l[a],l[b] = l[b],l[a] 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s675933018
p00011
Runtime Error
a=[i+1 for i in range(int(input()))] 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s484030890
p00011
Runtime Error
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:s*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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s420396297
p00011
Runtime Error
import math tate =int(input()) yoko=int(input()) arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split() rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s460084583
p00011
Runtime Error
tate =int(input()) yoko=int(input()) arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split() rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s202557140
p00011
Runtime Error
tate =int(input()); yoko=int(input()); arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split() rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s115734457
p00011
Runtime Error
tate =int(input()); yoko=int(input()); arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split(); rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s067957806
p00011
Runtime Error
tate =int(input()); yoko=int(input()); arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split(); rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s696794372
p00011
Runtime Error
tate =int(raw_input()) yoko=int(raw_input()) arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=raw_input().split(); rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s395143450
p00011
Runtime Error
import math tate =int(input()) yoko=int(input()) arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split(); rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k])
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s177066699
p00011
Runtime Error
import math tate =int(input()) yoko=int(input()) arr = [i+1 for i in range(tate)] for j in range(yoko): rep1,rep2=input().split(); rep1=int(rep1)-1 rep2=int(rep2)-1 arr[rep1],arr[rep2] = arr[rep2],arr[rep1] for k in range(tate): print(arr[k] )
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s410185900
p00011
Runtime Error
w=input() l=[i+1 for i in range(w)] n=input() for _ in range(n): a,b=[int(i)-1 for i in input().split(",")] t=l[a] l[a]=l[b] l[b]=t for i in w: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s439164576
p00011
Runtime Error
w=int(input()) l=[i+1 for i in range(w)] n=int(input()) for _ in range(n): a,b=[int(i)-1 for i in input().split(",")] t=l[a] l[a]=l[b] l[b]=t for i in w: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s000924005
p00011
Runtime Error
w = int(input()) n = int(input()) nums = [1, 2, 3, 4, 5] ab = [] for i in range(n): a, b = map(int, input().split(',')) nums[a-1], nums[b-1] = nums[b-1], nums[a-1] for i in nums: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s641885342
p00011
Runtime Error
w = int(input()) n = int(input()) amida = [] for i in range(0,w+1): amida.append(i) for i in range(n): ai,bi = map(int,input().split()) aa = amida[ai] bb = amida[bi] amida[ai] = bb amida[bi] = aa for i in range(1,w+1): print(w[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s277533855
p00011
Runtime Error
import sys re = range(input()) for li in sys.stdin: [a,b] = [int(x) for x in li.split(",")] tmp = re[a-1] re[a-1] = re[b-1] re[b-1] = tmp for i in re: print 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s924138953
p00011
Runtime Error
import sys re = range(int(raw_input())) for li in sys.stdin: [a,b] = [int(x) for x in li.split(",")] tmp = re[a-1] re[a-1] = re[b-1] re[b-1] = tmp for i in re: print 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s001568972
p00011
Runtime Error
import sys swapDirections = [] for lincnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = range(1, n+1) for direction in swapDirections: ai, bi = direction result[ai], result[bi] = result[bi] , result[ai] print '\n'.join(map(str, result))
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s631510794
p00011
Runtime Error
import sys swapDirections = [] for lineCnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = range(1, n+1) for direction in swapDirections: ai, bi = direction result[ai], result[bi] = result[bi] , result[ai] print '\n'.join(map(str, result))
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s595264426
p00011
Runtime Error
import sys swapDirections = [] for lineCnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = range(1, n+1) for direction in swapDirections: ai, bi = tuple(direction) result[ai], result[bi] = result[bi] , result[ai] print '\n'.join(map(str, result))
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s442120279
p00011
Runtime Error
import sys swapDirections = [] for lineCnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = map(str, range(1, n+1)) for direction in swapDirections: ai, bi = direction[0], direction[1] result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result)
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s013918096
p00011
Runtime Error
import sys def entory(fobj=sys.stdin): swapDirections = [] for lineCnt, line in enumerate(fobj): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = map(str, range(1, n+1)) for direction in swapDirections: ai, bi = direction[0], direction[1] result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result) if __name__ == '__main__': entory()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s029357736
p00011
Runtime Error
import sys def entory(fobj=sys.stdin): swapDirections = [] for lineCnt, line in enumerate(fobj): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = map(str, range(1, n+1)) for direction in swapDirections: ai, bi = direction[0], direction[1] result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result) entory()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s876740951
p00011
Runtime Error
import sys def entory(fobj=sys.stdin): swapDirections = [] for lineCnt, line in enumerate(fobj): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = map(str, range(1, n+1)) for direction in swapDirections: ai, bi = direction[0], direction[1] result[ai], result[bi] = result[bi], result[ai] for n in result: print n entory()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s832493597
p00011
Runtime Error
import sys def entory(fobj=sys.stdin): swapDirections = [] for lineCnt, line in enumerate(fobj): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = map(str, range(1, w+1)) for direction in swapDirections: ai, bi = direction[0], direction[1] result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result) if __name__ == '__main__': entory()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s809113328
p00011
Runtime Error
import sys def entory(fobj=sys.stdin): swapDirections = [] for lineCnt, line in enumerate(fobj): if lineCnt == 0: w = int(line) elif lineCount == 1: n = int(line) else: swapDirections.append(map(int, line.split(','))) result = map(str, range(1, w+1)) for direction in swapDirections: ai, bi = direction[0]-1, direction[1]-1 result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result) if __name__ == '__main__': entory()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s436054220
p00011
Runtime Error
import sys def entory(fobj=sys.stdin) for lineCnt, line in enumerate(fobj): if lineCnt == 0: w = int(line) result = range(1, w+1) elif lineCount == 1: n = int(line) else: ai, bi = map(lambda x: int(x)-1, line.split(',')) result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result) if __name__ == '__main__': entory()
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s565819469
p00011
Runtime Error
import sys for lineCnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) result = range(1, w+1) elif lineCount == 1: n = int(line) else: ai, bi = map(lambda x: int(x)-1, line.split(',')) result[ai], result[bi] = result[bi], result[ai] print '\n'.join(result)
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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s890396371
p00011
Runtime Error
import sys for lineCnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) result = range(1, w+1) elif lineCount == 1: n = int(line) else: ai, bi = map(lambda x: int(x)-1, line.split(',')) result[ai], result[bi] = result[bi], result[ai] for num in result: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s219823172
p00011
Runtime Error
import sys result = [] for lineCnt, line in enumerate(sys.stdin): if lineCnt == 0: w = int(line) result = range(1, w+1) elif lineCount == 1: n = int(line) else: ai, bi = map(lambda x: int(x)-1, line.split(',')) result[ai], result[bi] = result[bi], result[ai] for num in result: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s572090545
p00011
Runtime Error
import math 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() import math 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s378462592
p00011
Runtime Error
# -*- coding: utf-8 -*- import sys #for line in ["0.0 3.0 -1.0 0.0 -3.0 4.0"]: # expected [-2.000, 2.000, 2.236] lineNumber = 0 for line in sys.stdin.readlines(): lineNumber += 1 # get data List = map(float, line.strip().split()) # initial parameter if lineNumber == 1: w = List[0] array = [i for i in xrange(1, w+1)] contiune if lineNumber == 2: continue # set data [a, b] = List a -= 1; b -= 1 # exchange buf = array[a] array[a] = array[b] array[b] = buf for i in xrange(w): print array[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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s029970909
p00011
Runtime Error
w = int(raw_input()) n = int(raw_input()) s = [i+1 for i in range(w)] for i in range(n): a, b = map(int, raw_input().split()) tmp = s[a-1] s[a-1] = s[b-1] s[b-1] = tmp 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s691908772
p00011
Runtime Error
w = int(raw_input())$ 2 n = int(raw_input())$ 3 a = []$ 4 for i in range(n):$ 5 a.append(map(int, raw_input().split(',')))$ 6 r = range(1,w + 1)$ 7 for i in a:$ 8 tmp = r[i[0] - 1]$ 9 r[i[0] - 1] = r[i[1] - 1]$ 10 r[i[1] - 1] = tmp$ 11 for i in r:$ 12 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s783529237
p00011
Runtime Error
w = int(raw_input()) n = int(raw_input())$ a = [] for i in range(n): a.append(map(int, raw_input().split(','))) r = range(1,w + 1) for i in a: tmp = r[i[0] - 1] r[i[0] - 1] = r[i[1] - 1] r[i[1] - 1] = tmp for i in r: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s201206477
p00011
Runtime Error
w = int(raw_input()) n = int(raw_input()) a = [] for i in range(n): a.append(map(int, raw_input().split(','))) r = range(1,w + 1) for i in a: tmp = r[i[0] - 1] r[i[0] - 1] = r[i[1] - 1] r[i[1] - 1] = tmp for i in r: 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> &le; 30) is the number of vertical lines. <var>n</var> (<var>n</var> &le; 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> -->
s074903538
p00012
Wrong Answer
# coding: utf-8 #Problem Name: A Point in a Triangle #ID: tabris #Mail: t123037@kaiyodai.ac.jp def check(p1,p2): global xp,yp if p1[0] == p2[0]: return False elif p1[1] == p2[1]: if yp > p1[1]: return True else: return False else: a = (p2[1]-p1[1])/(p2[0]-p1[0]) b = p1[1] - a*p1[0] if yp > a*xp+b: return True else: return False while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split(' ')) upper = [0]*3 upper[0] = check([x1,y1],[x2,y2]) upper[1] = check([x2,y2],[x3,y3]) upper[2] = check([x3,y3],[x1,y1]) if True in upper and False in upper: print 'YES' else: print 'NO' except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s270241727
p00012
Wrong Answer
# coding: utf-8 #Problem Name: A Point in a Triangle #ID: tabris #Mail: t123037@kaiyodai.ac.jp def check(p1,p2): global xp,yp if p1[0] == p2[0]: return False elif p1[1] == p2[1]: if yp > p1[1]: return True else: return False else: a = (p2[1]-p1[1])/(p2[0]-p1[0]) b = p1[1] - a*p1[0] if yp > a*xp+b: return True else: return False while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split(' ')) upper = [0]*3 upper[0] = check([x1,y1],[x2,y2]) upper[1] = check([x2,y2],[x3,y3]) upper[2] = check([x3,y3],[x1,y1]) if max(y1,y2,y3) > yp > min(y1,y2,y3) and max(x1,x2,x3) > xp > min(x1,x2,x3) and True in upper and False in upper: print 'YES' else: print 'NO' except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s235154696
p00012
Wrong Answer
while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().strip().split(' ')) x = sorted([x1, x2, x3, xp]) y = sorted([y1, y2, y3, yp]) if x.index(xp) > 0 and x.index(xp) < 3 and y.index(yp) > 0 and y.index(yp) < 3: print "YES" else: print "NO" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s066402198
p00012
Wrong Answer
import sys def area(x1,y1,x2,y2,x3,y3): return abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2))/2.0) for line in sys.stdin.readlines(): x1, y1, x2, y2, x3, y3, xp, yp=map(float,line.split()) a1=area(x1,y1,x2,y2,xp,yp) a2=area(x3,y3,x2,y2,xp,yp) a3=area(x1,y1,x3,y3,xp,yp) a=area(x1,y1,x2,y2,x3,y3) if(a==(a1+a2+a3)): print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s079533423
p00012
Wrong Answer
#encoding=utf-8 import sys import math def inp(): for i in sys.stdin: x1,y1,x2,y2,x3,y3,xp,yp = map(float, i.split()) p = ((y1 - y3)*(y1**2 - y1**2 + x1**2 - x2**2) - (y1 - y2)*(y1**2 - y3**2 + x1**2 - x3**2))/(2*(y1 - y3)*(x1 - x2) - 2*(y1 - y2)*(x1 - x3)) q = ((x1 - x3)*(x1**2 - x2**2 + y1**2 - y2**2) - (x1 - x2)*(x1**2 - x3**2 + y1**2 - y3**2))/(2*(x1 - x3)*(y1 - y2) - 2*(x1 - x2)*(y1 - y3)) a,b = rennritu(x1,y1,x2,y2) c1 = hantei(a,b,p,q,xp,yp) a,b = rennritu(x2,y2,x3,y3) c2 = hantei(a,b,p,q,xp,yp) a,b = rennritu(x3,y3,x1,y1) c3 = hantei(a,b,p,q,xp,yp) if c1 == c2 == c3: print "Yes" else: print "No" def rennritu(x1,y1,x2,y2): if x1 == 0: if y1 == 0: return 1,1 else: return 0,y1 elif y1 == 0: return x1,0 elif x2 == 0: if y2 == 0: return 0,0 else: return 0,y2 elif y2 == 0: return x2,0 else: a = (y1 - y2)/(x1 - x2) b = y1 - (a*x1) return a,b def hantei(a,b,p,q,xp,yp): z1 = niji(a,b,p,q) z2 = niji(a,b,xp,yp) if z1 == z2: return 1 else: return 0 def niji(a,b,x,y): if y < a*x + b: return 0 else: return 1 if __name__ == "__main__": inp()
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s003599031
p00012
Wrong Answer
# -*- coding: utf-8 -*- import sys import math class Point_Class(): def __init__(self, x, y): self.x = x self.y = y def isIn(p1, p2, p3, pp): a = p2.y-p1.y b = p2.x-p1.x c = p2.x*p1.y-p1.x*p2.y d = p3.y-p2.y e = p3.x-p2.x f = p3.x*p2.y-p2.x*p3.y g = p1.y-p3.y h = p1.x-p3.x i = p1.x*p3.y-p1.x*p3.y left_12 = left_23 = left_31 = True if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0: left_12 = False if (d*pp.x-e*pp.y+f)*(d*p3.x-e*p3.y+f) < 0: left_23 = False if (g*pp.x-h*pp.y+i)*(g*p3.x-h*p3.y+i) < 0: left_31 = False if left_12 == left_23 and left_23 == left_31: return True else: return False for line in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) p1 = Point_Class(x1, y1) p2 = Point_Class(x2, y2) p3 = Point_Class(x3, y3) pp = Point_Class(xp, yp) print "YES" if isIn(p1, p2, p3, pp) else "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s837173943
p00012
Wrong Answer
# -*- coding: utf-8 -*- import sys import math class Point_Class(): def __init__(self, x, y): self.x = x self.y = y def isIn(p1, p2, p3, pp): a = p2.y-p1.y b = p2.x-p1.x c = p2.x*p1.y-p1.x*p2.y d = p3.y-p2.y e = p3.x-p2.x f = p3.x*p2.y-p2.x*p3.y g = p1.y-p3.y h = p1.x-p3.x i = p1.x*p3.y-p1.x*p3.y left_12 = left_23 = left_31 = True if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0: left_12 = False if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0: left_23 = False if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0: left_31 = False print left_12, left_23, left_31 if left_12 == left_23 == left_31: return True else: return False for line in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) p1 = Point_Class(x1, y1) p2 = Point_Class(x2, y2) p3 = Point_Class(x3, y3) pp = Point_Class(xp, yp) print "YES" if isIn(p1, p2, p3, pp) else "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s552396321
p00012
Wrong Answer
# -*- coding: utf-8 -*- import sys import math class Point_Class(): def __init__(self, x, y): self.x = x self.y = y def isIn(p1, p2, p3, pp): a = p2.y-p1.y b = p2.x-p1.x c = p2.x*p1.y-p1.x*p2.y d = p3.y-p2.y e = p3.x-p2.x f = p3.x*p2.y-p2.x*p3.y g = p1.y-p3.y h = p1.x-p3.x i = p1.x*p3.y-p1.x*p3.y left_12 = left_23 = left_31 = True if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0: left_12 = False if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0: left_23 = False if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0: left_31 = False if left_12 == left_23 == left_31: return True else: return False for line in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) p1 = Point_Class(x1, y1) p2 = Point_Class(x2, y2) p3 = Point_Class(x3, y3) pp = Point_Class(xp, yp) print "YES" if isIn(p1, p2, p3, pp) else "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s439120014
p00012
Wrong Answer
# -*- coding: utf-8 -*- import sys import math class Point_Class(): def __init__(self, x, y): self.x = x self.y = y def isIn(p1, p2, p3, pp): a = p2.y-p1.y b = p2.x-p1.x c = p2.x*p1.y-p1.x*p2.y d = p3.y-p2.y e = p3.x-p2.x f = p3.x*p2.y-p2.x*p3.y g = p1.y-p3.y h = p1.x-p3.x i = p1.x*p3.y-p1.x*p3.y if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0: return False if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0: return False if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0: return False return True for line in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) p1 = Point_Class(x1, y1) p2 = Point_Class(x2, y2) p3 = Point_Class(x3, y3) pp = Point_Class(xp, yp) print "YES" if isIn(p1, p2, p3, pp) else "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s149192471
p00012
Wrong Answer
import sys def crossMulti(p1, p2): return p1[0] * p2[1] - p1[1] * p2[0] lines = sys.stdin.readlines() for line in lines: Zd = [] x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)] Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)] for p in range(3): Zd.append(crossMulti(Ps[p], Px[p])) Zd = [x > 0 for x in Zd] if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]): print('Yes') else: print('No')
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s984359674
p00012
Wrong Answer
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.a = math.sqrt((x1-x2) ** 2 + (y1 - y2) ** 2) self.b = math.sqrt((x2-x3) ** 2 + (y2 - y3) ** 2) self.c = math.sqrt((x1-x3) ** 2 + (y1 - y3) ** 2) def get_acos_a(self): val = (-self.a ** 2 + self.b ** 2 + self.c ** 2) / (2 * self.b * self.c) return math.acos(val) while(1): try: x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split())) t1 = Triangle(x1, y1, x2, y2, xp, yp) t2 = Triangle(x2, y2, x3, y3, xp, yp) t3 = Triangle(x3, y3, x1, y1, xp, yp) if 6.283 <= t1.get_acos_a() + t2.get_acos_a() + t3.get_acos_a() <= 6.284: print("YES") else: print("NO") except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s862765931
p00012
Wrong Answer
out=[] while True: try: k=list(map(float,input().split(" "))) except: break O_x,O_y=k[0],k[1] A_x,A_y=k[2],k[3] B_x,B_y=k[4],k[5] P_x,P_y=k[6],k[7] # P in triangle OAB # iff s+t<1 and s>0 and t>0 (OP=sOA+tOB) OA=(A_x-O_x,A_y-O_y) OB=(B_x-O_x,B_y-O_y) OP=(P_x-O_x,P_y-O_y) keisuu=1/( OA[0]*OB[1] - OA[1]*OB[0] ) s=keisuu*( OB[1]*OP[0]-OB[0]*OP[1] ) t=keisuu*( -OA[1]*OP[0]+OA[0]*OP[1] ) if s>0 and t>0 and s+t>0: out.append("YES") else: out.append("NO") for i in out: print(i)
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s940998935
p00012
Wrong Answer
def Cramer(a11, a12, a13, a21, a22, a23): den = a11 * a22 - a12 * a21 return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den while True: try: x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()] u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1) print('YES' if u >= 0.0 and v >= 0.0 and u + v - 1.0 < 1e10 else 'NO') except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s300436621
p00012
Wrong Answer
def Cramer(a11, a12, a13, a21, a22, a23): den = a11 * a22 - a12 * a21 return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den while True: try: x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()] u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1) print('YES' if u >= 0.0 and v >= 0.0 and abs(u + v - 1.0) < 1e10 else 'NO') except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s199765739
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < math.pi: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s757625051
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < math.pi-1e-5: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s276371911
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s607953768
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-5: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s767566307
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-5: print('NO') print(sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3))) else: print('YES') print(sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3))) except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s024758019
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) <= 2 * math.pi: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s368404019
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-3: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s919280781
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:max(min((a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5),1),-1) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s922927253
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x:x-xp, x)) y = list(map(lambda y:y-yp, y)) cos = lambda a1,a2,b1,b2:max(min((a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5),1),-1) if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-6: print('NO') else: print('YES') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s933625106
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x: x - xp, x)) y = list(map(lambda y: y - yp, y)) s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1) if sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) == s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0]): print('YES') else: print('NO')
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s700350267
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x: x - xp, x)) y = list(map(lambda y: y - yp, y)) s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1) if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < 1e-10: print('YES') else: print('NO')
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s087212005
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x: x - xp, x)) y = list(map(lambda y: y - yp, y)) s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1) if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < 1e-15: print('YES') else: print('NO')
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s292074982
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x: x - xp, x)) y = list(map(lambda y: y - yp, y)) s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1) if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < 1e-5: print('YES') else: print('NO')
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s142596985
p00012
Wrong Answer
import math while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break x = [x1, x3, x3, x1] y = [y1, y2, y3, y1] x = list(map(lambda x: x - xp, x)) y = list(map(lambda y: y - yp, y)) s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1) if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < .00001: print('YES') else: print('NO')
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s684996067
p00012
Wrong Answer
class point: def __init__(self, x, y): self.x = x self.y = y def sub(self, p): return point(self.x - p.x, self.y - p.y) while 1: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) A = point(x1, y1) B = point(x2, y2) C = point(x3, y3) P = point(xp, yp) AB = B.sub(A) BP = P.sub(B) BC = C.sub(B) CP = P.sub(C) CA = A.sub(C) AP = P.sub(A) c1 = AB.x * BP.y - AB.y * BP.x c2 = BC.x * CP.y - BC.y * CP.x c3 = CA.x * AP.y - CA.y * AP.x if((c1 > 0) and (c2 > 0) and (c3 > 0) or (c1 < 0) and (c2 < 0) and (c3 < 0)): print YES else: print NO except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s326081303
p00012
Wrong Answer
class vector(object): def __init__(self,a,b): self.x=b.x-a.x self.y=b.y-a.y @staticmethod def cross_product(a,b): return a.x*b.y-a.y*b.x class vertex(object): def __init__(self,a): self.x=a[0] self.y=a[1] class circle(object): def __init__(self,p,r): self.px=p.x self.py=p.y self.r=r class triangle(object): def __init__(self,a,b,c): self.a=a self.b=b self.c=c import math self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2) self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2) self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2) c=self.ab a=self.bc b=self.ca self.cosA=(b**2+c**2-a**2)/(2*b*c) self.cosB=(a**2+c**2-b**2)/(2*a*c) self.cosC=(b**2+a**2-c**2)/(2*b*a) self.sinA=math.sqrt(1-self.cosA**2) self.sinB=math.sqrt(1-self.cosB**2) self.sinC=math.sqrt(1-self.cosC**2) self.sin2A=2*self.sinA*self.cosA self.sin2B=2*self.sinB*self.cosB self.sin2C=2*self.sinC*self.cosC def area(self): import math s=(self.ab+self.bc+self.ca)/2 S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca)) return S def circumscribed(self): R=self.ab/(2*self.sinC) px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C) py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C) px=round(px,3) py=round(py,3) R=round(R,3) p=vertex((px,py)) return circle(p,R) def isin(self,p): AB=vector(self.a,self.b) BC=vector(self.b,self.c) CA=vector(self.c,self.a) AP=vector(self.a,p) BP=vector(self.b,p) CP=vector(self.c,p) if (vector.cross_product(AB,AP)>0 and vector.cross_product(BC,BP)>0 and vector.cross_product(CA,CP)>0)or(vector.cross_product(AB,AP)<0 and vector.cross_product(BC,BP)<0 and vector.cross_product(CA,CP)<0): return 'Yes' else:return 'No' A=[] B=[] C=[] p=[] import sys for line in sys.stdin: a,b,c,d,e,f,g,h=list(map(float,line.split())) A.append(vertex((a,b))) B.append(vertex((c,d))) C.append(vertex((e,f))) p.append(vertex((g,h))) for i in range(len(A)): Triangle=triangle(A[i],B[i],C[i]) print(Triangle.isin(p[i]))
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s281970004
p00012
Wrong Answer
# -*- coding:utf-8 -*- import sys import math def norm(x1,y1,x2,y2): r = math.sqrt((x2 - x1)**2 + (y2 - y1)**2) return r def judge(x1,y1,x2,y2,x3,y3,xp,yp): r1 = norm(x1,y1,x2,y2) r2 = norm(x2,y2,x3,y3) r3 = norm(x3,y3,x1,y1) d1 = norm(xp,yp,x1,y1) d2 = norm(xp,yp,x2,y2) d3 = norm(xp,yp,x3,y3) if d1 > r1 or d1 > r3: print('NO') elif d2 > r1 or d2 > r2: print('NO') elif d3 > r3 or d3 > r2: print('NO') else: print('YES') array = [] for i in sys.stdin: array.append(i) for i in range(len(array)): tmp = array[i] x1,y1,x2,y2,x3,y3,xp,yp = map(float,tmp.split(' ')) judge(x1,y1,x2,y2,x3,y3,xp,yp)
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s612329349
p00012
Wrong Answer
# -*- coding:utf-8 -*- import sys import math def norm(x1,y1,x2,y2): r = math.sqrt((x2 - x1)**2 + (y2 - y1)**2) return r def judge(x1,y1,x2,y2,x3,y3,xp,yp): r1 = norm(x1,y1,x2,y2) r2 = norm(x2,y2,x3,y3) r3 = norm(x3,y3,x1,y1) d1 = norm(xp,yp,x1,y1) d2 = norm(xp,yp,x2,y2) d3 = norm(xp,yp,x3,y3) if d1 > r1 or d1 > r3: print('NO') elif d2 > r1 or d2 > r2: print('NO') elif d3 > r3 or d3 > r2: print('NO') else: print('YES') array = [] for i in sys.stdin: array.append(i) for i in range(len(array)): tmp = array[i] x1,y1,x2,y2,x3,y3,xp,yp = map(float,tmp.split(' ')) judge(x1,y1,x2,y2,x3,y3,xp,yp)
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s926025185
p00012
Wrong Answer
import math def tri(x1, y1, x2, y2, x3, y3): return math.fabs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2 while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break abc = tri(x1, y1, x2, y2, x3, y3) abp = tri(x1, y1, x2, y2, xp, yp) acp = tri(x1, y1, x3, y3, xp, yp) bcp = tri(x2, y2, x3, y3, xp, yp) print("YES" if abc>=abp+acp+bcp else "NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s127638441
p00012
Wrong Answer
import sys lines = str(sys.stdin.read()).strip().split("\n") for line in lines: data = line.split(" ") x1 = data[0] y1 = data[1] x2 = data[2] y2 = data[3] x3 = data[4] y3 = data[5] xp = data[6] yp = data[7] if xp > min(x1, x2, x3) and xp < max(x1, x2, x3) and yp > min(y1, y2, y3) and yp < max(y1, y2, y3): print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s214340239
p00012
Wrong Answer
import sys lines = str(sys.stdin.read()).strip().split("\n") for line in lines: data = line.split(" ") x1 = float(data[0]) y1 = float(data[1]) x2 = float(data[2]) y2 = float(data[3]) x3 = float(data[4]) y3 = float(data[5]) xp = float(data[6]) yp = float(data[7]) if xp > min(x1, x2, x3) and xp < max(x1, x2, x3) and yp > min(y1, y2, y3) and yp < max(y1, y2, y3): print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s763448027
p00012
Wrong Answer
try: while True: li = [float(x) for x in input().split()] lix = [li[i] for i in range(6) if i % 2 == 0] liy = [li[i] for i in range(6) if i % 2 != 0] x, y = li[6], li[7] if min(lix) < x < max(lix) and min(liy) < y < max(liy): print("YES") else: print("NO") except EOFError: pass
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s469964339
p00012
Wrong Answer
try: while True: li = [float(x) for x in input().split()] lix = [li[i] for i in range(6) if i % 2 == 0] liy = [li[i] for i in range(6) if i % 2 != 0] x, y = li[6], li[7] if min(lix) <= x <= max(lix) and min(liy) <= y <= max(liy): print("YES") else: print("NO") except EOFError: pass
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s272784683
p00012
Wrong Answer
try: while True: li = [float(x) for x in input().split()] if li: lix = [li[i] for i in range(6) if i % 2 == 0] liy = [li[i] for i in range(6) if i % 2 != 0] x, y = li[6], li[7] if min(lix) <= x <= max(lix) and min(liy) <= y <= max(liy): print("YES") else: print("NO") except EOFError: pass
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s840973475
p00012
Wrong Answer
try: while True: li = [float(x) for x in input().split()] if li: lix = [li[i] for i in range(6) if i % 2 == 0] liy = [li[i] for i in range(6) if i % 2 != 0] x, y = li[6], li[7] if min(lix) < x < max(lix) and min(liy) < y < max(liy): print("YES") else: print("NO") except EOFError: pass
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s745118784
p00012
Wrong Answer
while True: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split()) if xp<0 or yp<0: print('No') else: print('Yes') except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s355493514
p00012
Wrong Answer
length=[float(0) for i in range(3)] while 1: try: x1,y1,x2,y2,x3,y3,x4,y4=[float(i) for i in input().split( )] len1=(x1-x2)**2+(y1-y2)**2 len2=(x2-x3)**2+(y2-y3)**2 len3=(x3-x1)**2+(y3-y1)**2 length[0]=(x1-x4)**2+(y1-y4)**2 length[1]=(x2-x4)**2+(y2-y4)**2 length[2]=(x3-x4)**2+(y3-y4)**2 if ((max(length)>len1)and(max(length)>len2)and(max(length)>len3)): print("NO") else: print("YES") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s521255544
p00012
Wrong Answer
import math import sys def get_triangle_area(x1, y1, x2, y2, x3, y3): l1 = math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2) l2 = math.sqrt(abs(x2-x3)**2+abs(y2-y3)**2) l3 = math.sqrt(abs(x3-x1)**2+abs(y3-y1)**2) s = (l1+l2+l3)/2 return math.sqrt(s*(s-l1)*(s-l2)*(s-l3)) for l in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, l.split()) s1 = get_triangle_area(x1, y1, x2, y2, x3, y3) s2 = get_triangle_area(xp, yp, x1, y1, x2, y2) s2 += get_triangle_area(xp, yp, x2, y2, x3, y3) s2 += get_triangle_area(xp, yp, x3, y3, x1, y1) print("YES" if round(s1, 10) == round(s2, 10) else "NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s288655468
p00012
Wrong Answer
import sys def outer(vec_a, vec_b): return vec_a[0] * vec_b[1] - vec_a[1] * vec_b[0] try: while True: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) vec_12 = [x2-x1, y2-y1] vec_23 = [x3-x2, y3-y2] vec_31 = [x1-x3, y1-y3] vec_1p = [xp-x1, yp-y1] vec_2p = [xp-x2, yp-y2] vec_3p = [xp-x3, yp-y3] if (outer(vec_12, vec_1p) > 0 and outer(vec_23, vec_2p) > 0 and outer(vec_31, vec_3p) > 0): print('YES') else: print('NO') except: sys.exit()
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s490026081
p00012
Wrong Answer
# ????§???¢???????????????????????????sgn????????? from sys import stdin for line in stdin: x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in line.split()] ab_cross_ap = (x2-x1)*(y1-yp)-(y2-y1)*(x1-xp) bc_cross_bp = (x3-x2)*(y2-yp)-(y3-y2)*(x2-xp) ca_cross_cp = (x1-x3)*(y3-yp)-(y1-y3)*(x3-xp) if ab_cross_ap < 0 and bc_cross_bp < 0 and ca_cross_cp: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s243079604
p00012
Wrong Answer
from sys import stdin for line in stdin: x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in line.split()] ab_cross_ap = (x2-x1)*(y1-yp)-(y2-y1)*(x1-xp) bc_cross_bp = (x3-x2)*(y2-yp)-(y3-y2)*(x2-xp) ca_cross_cp = (x1-x3)*(y3-yp)-(y1-y3)*(x3-xp) if ab_cross_ap < 0 and bc_cross_bp < 0 and ca_cross_cp < 0: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s393096926
p00012
Wrong Answer
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()] x_vector_1to2=x2-x1; y_vector_1to2=y2-y1; x_vector_1to3=x3-x1; y_vector_1to3=y3-y1; x_vector_p=xp-x1; y_vector_p=yp-y1; def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u a=p; b=q; c=r; d=s; e=t; f=u; a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a; res_y=b1-e1; if res_y != 0 : res_y =(c1-f1)/res_y; res_x =(c-b*res_y)/a; return(res_x,res_y) else: return(-1,-1) res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p) if res[0]>0 and res[1]>0 and res[0]+res[1]<1: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s142326194
p00012
Wrong Answer
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()] x_vector_1to2=x2-x1; y_vector_1to2=y2-y1; x_vector_1to3=x3-x1; y_vector_1to3=y3-y1; x_vector_p=xp-x1; y_vector_p=yp-y1; def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u a=p; b=q; c=r; d=s; e=t; f=u; a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a; res_y=b1-e1; if res_y != 0 : res_y =(c1-f1)/res_y; res_x =(c-b*res_y)/a; return(res_x,res_y) else: return(-1,-1) res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p) if res[0] >=0 and res[1] >=0 and res[0]+res[1]<1: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s313651029
p00012
Wrong Answer
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()] x_vector_1to2=x2-x1; y_vector_1to2=y2-y1; x_vector_1to3=x3-x1; y_vector_1to3=y3-y1; x_vector_p=xp-x1; y_vector_p=yp-y1; def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u a=p; b=q; c=r; d=s; e=t; f=u; a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a; res_y=b1-e1; if res_y != 0 : res_y =(c1-f1)/res_y; res_x =(c-b*res_y)/a; return(res_x,res_y) else: return(-1,-1) res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p) if res[0] >=0 and res[1] >=0 and res[0]+res[1]<=1: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<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>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>