s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s211682068
p00012
u633068244
1397397147
Python
Python
py
Accepted
20
4444
510
import math def S(a,b,c): s = (a+b+c)/2 return math.sqrt(s*(s-a)*(s-b)*(s-c)) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a = math.sqrt((x1-x2)**2+(y1-y2)**2) b = math.sqrt((x1-x3)**2+(y1-y3)**2) c = math.sqrt((x2-x3)**2+(y2-y3)**2) xa = math.sqrt((x3-xp)**2+(y3-yp)**2) xb = math.sqrt((x2-xp)**2+(y2-yp)**2) xc = math.sqrt((x1-xp)**2+(y1-yp)**2) if S(a,xb,xc)+S(b,xc,xa)+S(c,xa,xb)-S(a,b,c) > 0.0000001: print "NO" else: print "YES" except: break
p00012
<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>
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
5,602
s981947697
p00012
u633068244
1397397158
Python
Python
py
Accepted
20
4448
510
import math def S(a,b,c): s = (a+b+c)/2 return math.sqrt(s*(s-a)*(s-b)*(s-c)) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a = math.sqrt((x1-x2)**2+(y1-y2)**2) b = math.sqrt((x1-x3)**2+(y1-y3)**2) c = math.sqrt((x2-x3)**2+(y2-y3)**2) xa = math.sqrt((x3-xp)**2+(y3-yp)**2) xb = math.sqrt((x2-xp)**2+(y2-yp)**2) xc = math.sqrt((x1-xp)**2+(y1-yp)**2) if S(a,xb,xc)+S(b,xc,xa)+S(c,xa,xb)-S(a,b,c) > 0.0000001: print "NO" else: print "YES" except: break
p00012
<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>
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
5,603
s615569987
p00012
u633068244
1397398118
Python
Python
py
Accepted
10
4436
551
import math def L(x1,y1,x2,y2): return math.sqrt((x1-x2)**2+(y1-y2)**2) def S(a,b,c): s=(a+b+c)/2 return math.sqrt(s*(s-a)*(s-b)*(s-c)) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a = L(x1,y1,x2,y2) b = L(x1,y1,x3,y3) c = L(x2,y2,x3,y3) pa = L(x3,y3,xp,yp) pb = L(x2,y2,xp,yp) pc = L(x1,y1,xp,yp) if S(a,pb,pc)+S(b,pc,pa)+S(c,pa,pb)-S(a,b,c) > 0.0000001: print "NO" else: print "YES" except: break
p00012
<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>
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
5,604
s024195591
p00012
u708217907
1398176081
Python
Python
py
Accepted
10
4260
447
import sys def c(x1, y1, x2, y2, x, y): return (y2 - y1)*(x - x1) - (x2 - x1)*(y - y1) for str in sys.stdin: x1,y1,x2,y2,x3,y3,xp,yp = map(float, str.split(' ')) gx, gy = (x1 + x2 + x3)/3, (y1 + y2 + y3)/3 r1 = c(x1, y1, x2, y2, gx, gy)*c(x1, y1, x2, y2, xp, yp) > 0 r2 = c(x2, y2, x3, y3, gx, gy)*c(x2, y2, x3, y3, xp, yp) > 0 r3 = c(x3, y3, x1, y1, gx, gy)*c(x3, y3, x1, y1, xp, yp) > 0 print 'YES' if r1 and r2 and r3 else 'NO'
p00012
<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>
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
5,605
s245184305
p00012
u491763171
1400542128
Python
Python
py
Accepted
10
4284
690
while 1: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) except EOFError: break Points = [(x1, y1), (x2, y2), (x3, y3)] for i in xrange(3): A = Points[i] B = Points[(i + 1) % 3] C = Points[(i + 2) % 3] if A[0] - B[0] == 0: mark1 = C[0] - A[0] mark2 = xp - A[0] else: a = (A[1] - B[1]) / (A[0] - B[0]) b = A[1] - a * A[0] mark1 = C[1] - (a * C[0] + b) mark2 = yp - (a * xp + b) if not ((mark1 >= 0 and mark2 >= 0) or (mark1 <= 0 and mark2 <= 0)): print "NO" break else: print "YES"
p00012
<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>
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
5,606
s098119548
p00012
u708217907
1400905126
Python
Python
py
Accepted
10
4436
496
import math def L(x1,y1,x2,y2): return math.sqrt((x1-x2)**2+(y1-y2)**2) def S(a,b,c): s=(a+b+c)/2 return math.sqrt(s*(s-a)*(s-b)*(s-c)) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a = L(x1,y1,x2,y2) b = L(x1,y1,x3,y3) c = L(x2,y2,x3,y3) pa = L(x3,y3,xp,yp) pb = L(x2,y2,xp,yp) pc = L(x1,y1,xp,yp) if S(a,pb,pc)+S(b,pc,pa)+S(c,pa,pb)-S(a,b,c) > 0.0000001: print "NO" else: print "YES" except: break
p00012
<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>
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
5,607
s857559103
p00012
u708217907
1400905284
Python
Python
py
Accepted
10
4436
546
import math def L(x1, y1, x2, y2): return math.sqrt((x1 - x2)**2+(y1 - y2)**2) def S(a, b, c): s=(a + b + c)/2 return math.sqrt(s*(s - a)*(s - b)*(s - c)) while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) a = L(x1, y1, x2, y2) b = L(x1, y1, x3, y3) c = L(x2, y2, x3, y3) p1 = L(x1, y1, xp, yp) p2 = L(x2, y2, xp, yp) p3 = L(x3, y3, xp, yp) if S(a, p2, p1)+S(b, p1, p3)+S(c, p3, p2)-S(a, b, c) > 0.0000001: print "NO" else: print "YES" except: break
p00012
<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>
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
5,608
s662995989
p00012
u436634575
1401132410
Python
Python3
py
Accepted
30
6744
421
def r(x1, y1, x2, y2, x3, y3): return x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2) > 0 while True: try: line = input() except: break x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.strip().split()) abc = r(x1, y1, x2, y2, x3, y3) pab = r(xp, yp, x1, y1, x2, y2) pbc = r(xp, yp, x2, y2, x3, y3) pca = r(xp, yp, x3, y3, x1, y1) print('YES' if abc == pab == pbc == pca else 'NO')
p00012
<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>
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
5,609
s421233703
p00012
u813197825
1596330828
Python
Python3
py
Accepted
20
5600
1,464
# 2点(a, b) (c, d)を通る直線の傾きと切片を返す def func(a, b, c, d): k = (d - b) / (c - a) h = d - k * c return k, h # 2点と通る直線のf(x)を返す def fx(a, b, c, d, x): k, h = func(a, b, c, d) return k * x + h def main(): import sys for dataset in sys.stdin: ans = 'NO' try : a, b, c, d, e, f, px, py = map(float, dataset.split()) except: break T = [(a, b), (c, d), (e, f)] T.sort(key=lambda x: (x[0], x[1])) a, b, c, d, e, f = T[0][0], T[0][1], T[1][0], T[1][1], T[2][0], T[2][1] # 共通なxを持つ2点が存在するか判定し、する場合 if a == c: if a < px and fx(a, b, e, f, px) < py and fx(c, d, e, f, px) > py: ans = 'YES' elif c == e: if px < e and fx(a, b, c, d, px) < py and fx(a, b, e, f, px) > py: ans = 'YES' else: # 3点において共通のxを持たない場合 if fx(a, b, e, f, c) < d: # 中間点が残り2点を通る直線より上にあるケース if fx(a, b, c, d, px) > py and fx(c, d, e, f, px) > py and fx(a, b, e, f, px) < py: ans = 'YES' else: if fx(a, b, c, d, px) < py and fx(c, d, e, f, px) < py and fx(a, b, e, f, px) > py: ans = 'YES' print(ans) if __name__ == '__main__': main()
p00012
<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>
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
5,610
s820613274
p00012
u913305001
1594446218
Python
Python3
py
Accepted
20
5596
999
def cross_product(a,b):#a,bは複素数、だけどベクトル扱いしよう return (a.conjugate()*b).imag def abs_area_vector(ax,ay,bx,by):#3点(0,0)(ax,ay)(bx,by)で構成される三角形の面積の絶対値 return abs(0.5 * (cross_product(complex(ax,ay),complex(bx,by)))) def abs_area_3point(ax,ay,bx,by,cx,cy):#3点(ax,ay)(bx,by)(cx,cy)で構成される三角形の面積の絶対値 return abs_area_vector(bx-ax,by-ay,cx-ax,cy-ay) try: while True: x1,y1,x2,y2,x3,y3,xp,yp = map(float,input().split()) abc = abs_area_3point(x1,y1,x2,y2,x3,y3) pab = abs_area_3point(x1,y1,x2,y2,xp,yp) pbc = abs_area_3point(x2,y2,x3,y3,xp,yp) pca = abs_area_3point(x1,y1,x3,y3,xp,yp) #ここらへんで結構ミスあったから今度からはもっと簡潔に書けるように何か関数でも用意すべき print("NO" if pab * pbc * pca == 0 or abc != pab + pbc + pca else "YES") except (EOFError,ValueError): pass
p00012
<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>
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
5,611
s102745587
p00012
u742290340
1594029175
Python
Python3
py
Accepted
30
5600
418
try: while True: P= list(map(float,input().split())) a, b, c, q = [complex(P[i*2],P[i*2+1]) for i in range(4)] x,y,z= a-q,b-q,c-q xx= (x.conjugate()*y).imag yy= (y.conjugate()*z).imag zz= (z.conjugate()*x).imag if (xx>0 and yy>0 and zz>0) or (xx<0 and yy<0 and zz<0): print("YES") else: print("NO") except EOFError: pass
p00012
<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>
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
5,612
s485088124
p00012
u903393228
1594027862
Python
Python3
py
Accepted
30
5604
414
def cross_product(a,b): return (a.conjugate()*b).imag try: while True: P = list(map(float,input().split())) a, b, c, p = [complex(P[i*2],P[i*2+1]) for i in range(4)] S = cross_product(p-a,p-b) T = cross_product(p-b,p-c) U = cross_product(p-c,p-a) if S*T > 0 and T*U >0: print('YES') else: print('NO') except EOFError: pass
p00012
<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>
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
5,613
s597178580
p00012
u647214684
1594026045
Python
Python3
py
Accepted
20
5596
518
try: while True: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) a = complex(x1, y1) b = complex(x2, y2) c = complex(x3, y3) p = complex(xp, yp) s1 = ((a - p).conjugate() * (b - p)).imag s2 = ((b - p).conjugate() * (c - p)).imag s3 = ((c - p).conjugate() * (a - p)).imag if (s1 > 0) ^ (s2 > 0) == False and (s2 > 0) ^ (s3 > 0) == False: print('YES') else: print("NO") except EOFError: exit()
p00012
<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>
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
5,614
s971676774
p00012
u515473089
1594026035
Python
Python3
py
Accepted
20
5700
492
import math import cmath def dot(a:complex,b:complex): return (a.conjugate()*b).real def cross(a:complex,b:complex): return (a.conjugate()*b).imag next=[1,2,0] try: while True: l=list(map(float,input().split())) p=[complex(l[2*j],l[2*j+1]) for j in range(4)] flg_ans=True sgn=1 if cross(p[0]-p[3],p[1]-p[3])>0 else -1 for i in range(3): flg_ans=flg_ans and (sgn*cross(p[i]-p[3],p[next[i]]-p[3]))>0 print('YES' if flg_ans else 'NO') except EOFError: pass
p00012
<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>
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
5,615
s816777353
p00012
u187074069
1592488250
Python
Python3
py
Accepted
20
5592
1,261
def stl1(x): if a == e: y = b else: y = (f-b)*(x-a)/(e-a) +b return(y) def stl2(x): if c == e: y = f else: y = (d-f)*(x-e)/(c-e) +f return(y) def stl3(x): if c == a: y = b else: y = (d-b)*(x-a)/(c-a) +b return(y) while True: try: lst = list(map(float, input().split())) point1 = [lst[0], lst[1]] point2 = [lst[2], lst[3]] point3 = [lst[4], lst[5]] xp, yp = lst[6], lst[7] pointlst = [point1, point2, point3] pointlst.sort() a, b, e, f, c, d = pointlst[0][0], pointlst[0][1], pointlst[1][0], pointlst[1][1], pointlst[2][0], pointlst[2][1] if a <= xp and xp <= e: bdr1 = stl1(xp) bdr3 = stl3(xp) if min(bdr1, bdr3) <= yp and yp <= max(bdr1, bdr3): print("YES") else: print("NO") elif e < xp and xp <= c: bdr2 = stl2(xp) bdr3 = stl3(xp) if min(bdr2, bdr3) <= yp and yp <= max(bdr2, bdr3): print("YES") else: print("NO") else: print("NO") except EOFError: break
p00012
<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>
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
5,616
s273398514
p00012
u260980560
1588729874
Python
Python3
py
Accepted
20
5588
440
def cross3(a, b, c): return (b[0] - a[0])*(c[1] - a[1]) - (b[1] - a[1])*(c[0] - a[0]) for line in open(0).readlines(): x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) p1 = (x1, y1); p2 = (x2, y2); p3 = (x3, y3); pp = (xp, yp) if cross3(p1, p2, p3) < 0: p1, p2 = p2, p1 if cross3(p1, p2, pp) > 0 and cross3(p1, pp, p3) > 0 and cross3(p2, p3, pp) > 0: print("YES") else: print("NO")
p00012
<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>
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
5,617
s598054003
p00012
u942532706
1575468624
Python
Python3
py
Accepted
20
5588
458
while True: try: x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split())) sign = lambda x1, y1, x2, y2, x3, y3: (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3) b1 = sign(xp, yp, x1, y1, x2, y2) < 0.0 b2 = sign(xp, yp, x2, y2, x3, y3) < 0.0 b3 = sign(xp, yp, x3, y3, x1, y1) < 0.0 if b1 == b2 and b2 == b3: print("YES") else: print("NO") except: break
p00012
<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>
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
5,618
s440497827
p00012
u350155409
1575086488
Python
Python3
py
Accepted
20
5596
522
import sys for s in sys.stdin: x1,y1,x2,y2,x3,y3,xp,yp = [ float(x) for x in s.split() ] v12 = (x2-x1, y2-y1) v23 = (x3-x2, y3-y2) v31 = (x1-x3, y1-y3) v1p = (xp-x1, yp-y1) v2p = (xp-x2, yp-y2) v3p = (xp-x3, yp-y3) cp1 = v12[0]*v1p[1] - v1p[0]*v12[1] cp2 = v23[0]*v2p[1] - v2p[0]*v23[1] cp3 = v31[0]*v3p[1] - v3p[0]*v31[1] if cp1 > 0 and cp2 > 0 and cp3 > 0: print('YES') elif cp1 < 0 and cp2 < 0 and cp3 < 0: print('YES') else: print('NO')
p00012
<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>
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
5,619
s987811697
p00012
u037441960
1570772307
Python
Python3
py
Accepted
20
5592
835
while True : try : x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) # 三角形の回転方向で判定する # 三角形PAB, PBC, PCAの回転が全て同じならば、 # 点Pは三角形ABC内に存在する # 三角形ABCの回転の方向は、 # x1(y2 - y3) + x2(y3 - y1) + x3(y1 - y2) # の符号で判断できる # 正なら左周り、負なら右回り a = xp * (y1 - y2) + x1 * (y2 - yp) + x2 * (yp - y1) b = xp * (y2 - y3) + x2 * (y3 - yp) + x3 * (yp - y2) c = xp * (y3 - y1) + x3 * (y1 - yp) + x1 * (yp - y3) if((a < 0 and b < 0 and c < 0) or (a > 0 and b > 0 and c > 0)) : print("YES") else : print("NO") except : break
p00012
<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>
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
5,620
s099049921
p00012
u427219397
1564893693
Python
Python3
py
Accepted
20
5584
409
def r(a, b, c, d, e, f): return a * (d-f) + c * (f-b) + e * (b-d) > 0 while True: try: line = list(map(float, input().split())) except: break x1, y1, x2, y2, x3, y3, xp, yp = line abc = r(x1, y1, x2, y2, x3, y3) pab = r(xp, yp, x1, y1, x2, y2) pbc = r(xp, yp, x2, y2, x3, y3) pca = r(xp, yp, x3, y3, x1, y1) print('YES' if abc == pab == pbc == pca else 'NO')
p00012
<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>
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
5,621
s961107707
p00012
u529337794
1564707960
Python
Python3
py
Accepted
20
5588
193
import sys def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return[-1*(z==0),1][z>0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
p00012
<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>
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
5,622
s888069486
p00012
u678843586
1564645509
Python
Python3
py
Accepted
20
5588
192
import sys def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return[-1*(z==0),1][z>0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
p00012
<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>
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
5,623
s717960979
p00012
u804558166
1564585486
Python
Python3
py
Accepted
20
5588
405
def r(a, b, c, d, e, f): return a * (d-f) + c * (f-b) + e * (b-d) > 0 while True: try: line = list(map(float, input().split())) except: break x1, y1, x2, y2, x3, y3, xp, yp = line abc = r(x1, y1, x2, y2, x3, y3) pab = r(xp, yp, x1, y1, x2, y2) pbc = r(xp, yp, x2, y2, x3, y3) pca = r(xp, yp, x3, y3, x1, y1) print('YES' if abc == pab == pbc == pca else 'NO')
p00012
<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>
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
5,624
s254191030
p00012
u010611609
1562860316
Python
Python3
py
Accepted
30
5588
434
import sys def gaiseki(x0, y0, x1, y1): return x0*y1 - y0*x1 def muki(x0, y0, x1, y1, x2, y2): return gaiseki(x1-x0, y1-y0, x2-x1, y2-y1) > 0 for line in sys.stdin: x0, y0, x1, y1, x2, y2, xp, yp = map(float, line.split()) m0 = muki(xp, yp, x0, y0, x1, y1) m1 = muki(xp, yp, x1, y1, x2, y2) m2 = muki(xp, yp, x2, y2, x0, y0) if m0 == m1 and m1 == m2: print('YES') else: print('NO')
p00012
<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>
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
5,625
s060322257
p00012
u481944101
1562585200
Python
Python3
py
Accepted
20
5596
289
def isPos(p,x,y): return ((x-p).conjugate()*(y-p)).imag>0 try: while True: X=list(map(float,input().split())) a,b,c,p=map(lambda x:complex(*x),[X[:2],X[2:4],X[4:6],X[6:]]) print(['NO','YES'][isPos(p,a,b)==isPos(p,b,c)==isPos(p,c,a)]) except EOFError: pass
p00012
<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>
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
5,626
s611918698
p00012
u625806423
1553785179
Python
Python3
py
Accepted
20
5592
447
while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except EOFError: break vec_b = [x2-x1, y2-y1] vec_c = [x3-x1, y3-y1] vec_p = [xp-x1, yp-y1] a = (vec_p[0]*vec_c[1] - vec_p[1]*vec_c[0]) / (vec_b[0]*vec_c[1] - vec_b[1]*vec_c[0]) b = (vec_p[0]*vec_b[1] - vec_p[1]*vec_b[0]) / (vec_b[1]*vec_c[0] - vec_b[0]*vec_c[1]) if ((a > 0) and (b > 0) and (a+b < 1)): print("YES") else: print("NO")
p00012
<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>
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
5,627
s684054677
p00012
u990228206
1553158044
Python
Python3
py
Accepted
30
5688
689
while 1: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split()) a=((x1-x2)**2+(y1-y2)**2)**0.5 b=((x2-x3)**2+(y2-y3)**2)**0.5 c=((x3-x1)**2+(y3-y1)**2)**0.5 s=(a+b+c)/2 S=(s*(s-a)*(s-b)*(s-c))**0.5 d=((x1-xp)**2+(y1-yp)**2)**0.5 e=((x2-xp)**2+(y2-yp)**2)**0.5 f=((x3-xp)**2+(y3-yp)**2)**0.5 sa=(a+d+e)/2 sb=(b+e+f)/2 sc=(c+f+d)/2 Sa=(sa*(sa-a)*(sa-d)*(sa-e))**0.5 Sb=(sb*(sb-b)*(sb-e)*(sb-f))**0.5 Sc=(sc*(sc-c)*(sc-f)*(sc-d))**0.5 Sp=Sa+Sb+Sc if abs(S-Sp)<=0.001**2: print("YES") else: print("NO") except:break
p00012
<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>
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
5,628
s305490001
p00012
u689047545
1547135460
Python
Python3
py
Accepted
20
5584
649
if __name__ == '__main__': while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) ab = [x2-x1, y2-y1] bp = [xp-x2, yp-y2] bc = [x3-x2, y3-y2] cp = [xp-x3, yp-y3] ca = [x1-x3, y1-y3] ap = [xp-x1, yp-y1] c1 = ab[0]*bp[1] - ab[1]*bp[0] c2 = bc[0]*cp[1] - bc[1]*cp[0] c3 = ca[0]*ap[1] - ca[1]*ap[0] if (c1 > 0 and c2 > 0 and c3 > 0) or (c1 < 0 and c2 < 0 and c3 < 0): print("YES") else: print("NO") except EOFError: break
p00012
<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>
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
5,629
s479409352
p00012
u025180675
1544700695
Python
Python3
py
Accepted
20
5600
571
def cross(a,b): return (a.conjugate()*b).imag def is_in_triangle(X1,Y1,X2,Y2,X3,Y3,Xp,Yp): z1 = complex(X1-Xp,Y1-Yp) z2 = complex(X2-Xp,Y2-Yp) z3 = complex(X3-Xp,Y3-Yp) if cross(z1,z2) * cross(z2,z3) > 0: if cross(z2,z3) * cross(z3,z1) > 0: return True else: return False lst = [] try: while True: P = tuple(map(float,input().strip().split())) lst.append(P) except EOFError: pass N = len(lst) for i in range(N): if is_in_triangle(*lst[i]): print("YES") else: print("NO")
p00012
<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>
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
5,630
s896347313
p00012
u563075864
1542797965
Python
Python3
py
Accepted
30
5632
1,177
E = 10**-10 def cp(a, b): c = [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]] return c while True: try: x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in input().split()] ax = x3-x1 ay = y3-y1 bx = x1-x2 by = y1-y2 cx = x2-x3 cy = y2-y3 pax = xp-x1 pay = yp-y1 pbx = xp-x2 pby = yp-y2 pcx = xp-x3 pcy = yp-y3 ca = [bx,by,0] ab = [cx,cy,0] bc = [ax,ay,0] pa = [pax,pay,0] pb = [pbx,pby,0] pc = [pcx,pcy,0] cp1 = cp(ca,pa)[2] cp2 = cp(ab,pb)[2] cp3 = cp(bc,pc)[2] if abs(cp1 - abs(cp1)) < E: sig1 = 1 elif abs(cp1 + abs(cp1)) < E: sig1 = -1 if abs(cp2 - abs(cp2)) < E: sig2 = 1 elif abs(cp2 + abs(cp2)) < E: sig2 = -1 if abs(cp3 - abs(cp3)) < E: sig3 = 1 elif abs(cp3 + abs(cp3)) < E: sig3 = -1 if abs(sig1 + sig2 + sig3) == 3: print('YES') else: print('NO') except EOFError: break
p00012
<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>
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
5,631
s621105753
p00012
u219940997
1537448185
Python
Python3
py
Accepted
20
5584
402
def r(a, b, c, d, e, f): return a * (d-f) + c * (f-b) + e * (b-d) > 0 while True: try: line = list(map(float, input().split())) except: break x1, y1, x2, y2, x3, y3, xp, yp = line abc = r(x1, y1, x2, y2, x3, y3) pab = r(xp, yp, x1, y1, x2, y2) pbc = r(xp, yp, x2, y2, x3, y3) pca = r(xp, yp, x3, y3, x1, y1) print('YES' if abc == pab == pbc == pca else 'NO')
p00012
<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>
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
5,632
s376571060
p00012
u319725914
1534215074
Python
Python3
py
Accepted
20
5588
376
while(True): try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, input().split()) c1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1) c2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2) c3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3) if (c1<0 and c2<0 and c3<0) or (c1>0 and c2>0 and c3>0): print("YES") continue print("NO") except: break
p00012
<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>
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
5,633
s076897020
p00012
u252700163
1532753160
Python
Python3
py
Accepted
30
5996
540
from collections import namedtuple Point = namedtuple('Point', ('x', 'y')) def sign (p1, p2, p3): return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y); while True: try: x = list(map(float, input().split())) p1 = Point(x[0], x[1]) p2 = Point(x[2], x[3]) p3 = Point(x[4], x[5]) pp = Point(x[6], x[7]) b1 = sign(pp, p1, p2) < 0.0 b2 = sign(pp, p2, p3) < 0.0 b3 = sign(pp, p3, p1) < 0.0 if (b1 == b2) and(b2 == b3): print('YES') else: print('NO') except: break
p00012
<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>
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
5,634
s802122911
p00012
u539753516
1532324898
Python
Python3
py
Accepted
30
5588
372
def rot(xa,ya,xb,yb,xc,yc): r=(xb-xa)*(yc-ya)-(xc-xa)*(yb-ya) if r>0:return 1 if r==0:return 0 if r<0:return -1 while 1: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split(" ")) if rot(x1,y1,x2,y2,xp,yp)==rot(x2,y2,x3,y3,xp,yp)==rot(x3,y3,x1,y1,xp,yp): print("YES") else: print("NO") except:break
p00012
<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>
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
5,635
s079917837
p00012
u853158149
1521971866
Python
Python3
py
Accepted
20
5648
592
def point(a,b): return a[0]*b[0]+a[1]*b[1] def euclid(a): return (a[0]**2+a[1]**2)**(1/2) def cos(a,b): return point(a,b)/(euclid(a)*euclid(b)) while 1: try: ax,ay,bx,by,cx,cy,px,py = map(float, input().split(" ")) ab = [bx-ax, by-ay] ac = [cx-ax, cy-ay] ba = [ax-bx, ay-by] bc = [cx-bx, cy-by] ap = [px-ax, py-ay] bp = [px-bx, py-by] if min(cos(ab,ap),cos(ac,ap)) > cos(ab,ac) and min(cos(ba,bp),cos(bc,bp)) > cos(ba,bc): print("YES") else: print("NO") except: break
p00012
<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>
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
5,636
s495417517
p00012
u079141094
1467376801
Python
Python3
py
Accepted
30
7464
604
# A Point in a Triangle import math def simul_eq(a,b,c,d,e,f): # A = [[a,b],[d,e]] C = [c,f] detA = a*e - b*d # if detA == 0: raise # det(A) == 0. At = [[e,-b],[-d,a]] x = sum(map((lambda x,y: x*y), At[0], C)) / detA y = sum(map((lambda x,y: x*y), At[1], C)) / detA return (x,y) ss = input().split() while 1: x1,y1,x2,y2,x3,y3,xp,yp = map(float,ss) s,t = simul_eq(x2-x1, x3-x1, xp-x1, y2-y1, y3-y1, yp-y1) if 0 < s < 1 and 0 < t < 1 and 0 < s + t < 1: print('YES') else: print('NO') try: ss = input().split() except EOFError: break
p00012
<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>
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
5,637
s703592948
p00013
u995990363
1530857729
Python
Python3
py
Accepted
20
5600
212
import sys def run(): cars = [] for _n in sys.stdin: n = int(_n) if n == 0: print(cars.pop()) else: cars.append(n) if __name__ == '__main__': run()
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,638
s325857017
p00013
u553148578
1531533784
Python
Python3
py
Accepted
20
5596
220
counter = -1 train = [] while True: try: x = int(input()) except: break if x == 0 and len(train) != 0: print(train[counter]) train.remove(train[counter]) counter -= 1 else: train.append(x) counter += 1
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,639
s987365887
p00013
u525366883
1535446671
Python
Python
py
Accepted
0
4624
178
train = [] while True: try: n = int(raw_input()) if n == 0: print train.pop() else: train.append(n) except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,640
s636846046
p00013
u888548672
1555894911
Python
Python3
py
Accepted
20
5588
138
st = [] while 1: try: x = int(input()) st.append(x) if x != 0 else print(st.pop()) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,641
s452053224
p00013
u894015161
1559288139
Python
Python
py
Accepted
0
4636
186
stack = [] while True: try: data = int(input()) if data == 0: print stack.pop() else: stack.append(data) except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,642
s380117728
p00013
u555040407
1559366792
Python
Python3
py
Accepted
20
5604
227
# -*- coding: utf-8 -*- pile = [] while True: try: num = int(input()) if num != 0: pile.append(num) else: print(pile[-1]) pile.pop(-1) except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,643
s659723291
p00013
u506132575
1416117073
Python
Python
py
Accepted
20
4184
170
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys lis = [] for s in sys.stdin: d = int(s) if d == 0: print lis[-1] lis.pop() else: lis.append(d)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,644
s245779858
p00013
u342537066
1420711194
Python
Python3
py
Accepted
30
6724
210
lis=[] cnt=0 while True: try: n=int(input()) if n: cnt+=1 lis.append(n) else: print(lis.pop(cnt-1)) cnt-=1 except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,645
s361353078
p00013
u567380442
1422620204
Python
Python3
py
Accepted
30
6724
137
import sys cars = [] for line in sys.stdin: car = int(line) if car: cars.append(car) else: print(cars.pop())
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,646
s038827168
p00013
u929523932
1424138978
Python
Python3
py
Accepted
30
6724
174
stack = list() while (True): try: s = int(input()) except EOFError: break; if s == 0: print(stack.pop()) else: stack.append(s)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,647
s444065889
p00013
u879226672
1424157522
Python
Python
py
Accepted
10
4192
178
ls = [] while 1: try: n = int(raw_input()) except EOFError: break if n!=0: ls.append(n) else: print ls[-1] del ls[-1]
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,648
s206060020
p00013
u540744789
1425705526
Python
Python
py
Accepted
20
4188
124
import sys Rail = [] for S in sys.stdin: S=int(S) if S!=0: Rail.append(S) else: print Rail.pop()
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,649
s413827069
p00013
u145563629
1428923738
Python
Python
py
Accepted
20
4196
156
in_ = [] out = [] try: while 1: in_.append(raw_input()) if in_[-1] == "0": in_.pop() out.append(in_.pop()) except: pass for i in out: print(i)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,650
s542874524
p00013
u162387221
1431322545
Python
Python
py
Accepted
10
4188
155
ls = [] while True: try: n = int(raw_input()) except EOFError: break if n != 0: ls.append(n) else: print ls.pop()
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,651
s304110628
p00013
u067299340
1432899740
Python
Python
py
Accepted
20
4188
86
import sys s=[] for l in sys.stdin: n=int(l) if n==0:print s.pop() else:s.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,652
s891326089
p00013
u067299340
1432899750
Python
Python
py
Accepted
20
4180
86
import sys s=[] for l in sys.stdin: n=int(l) if n==0:print s.pop() else:s.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,653
s033696523
p00013
u067299340
1432899755
Python
Python
py
Accepted
10
4188
86
import sys s=[] for l in sys.stdin: n=int(l) if n==0:print s.pop() else:s.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,654
s188912840
p00013
u067299340
1433333649
Python
Python
py
Accepted
10
4188
85
import sys s=[] for n in map(int,sys.stdin): if n==0:print s.pop() else:s.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,655
s144528387
p00013
u873482706
1434355847
Python
Python
py
Accepted
10
4196
298
def get_input(): while True: try: yield raw_input() except EOFError: break num_lis = list(get_input()) train_lis = [] for num in num_lis: if num == '0': print(train_lis[0]) del train_lis[0] else: train_lis.insert(0, num)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,656
s469307955
p00013
u379956761
1434765433
Python
Python3
py
Accepted
30
6784
272
#!/usr/bin/env python #-*- coding:utf-8 -*- import sys import math railroad = [] outCar = [] for data in sys.stdin: data = int(data) if data != 0: railroad.append(data) else: outCar.append(railroad.pop()) for data in outCar: print(data)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,657
s971684499
p00013
u883062308
1438519282
Python
Python3
py
Accepted
30
6720
265
import sys cars = [] out_cars = [] cars_size = 0 for line in sys.stdin: n = int(line) if n == 0: out_cars.append(cars.pop(cars_size - 1)) cars_size -= 1 else: cars.append(n) cars_size += 1 [print(car) for car in out_cars]
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,658
s372937634
p00013
u766163292
1442936171
Python
Python3
py
Accepted
30
7340
263
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys def main(): stack = [] for a in sys.stdin.read().split("\n"): if a == "0": print(stack.pop()) else: stack.append(a) if __name__ == "__main__": main()
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,659
s862893564
p00013
u071010747
1445232458
Python
Python3
py
Accepted
30
7628
346
# -*- coding:utf-8 -*- def main(): LIST=[] while True: try: IN=int(input()) if IN==0: print(LIST[len(LIST)-1]) del LIST[len(LIST)-1] else: LIST.append(IN) except: break if __name__ == '__main__': main()
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,660
s310853044
p00013
u775586391
1448031082
Python
Python3
py
Accepted
50
7580
115
import sys l = [] for i in sys.stdin.readlines(): if int(i) == 0: print(l.pop()) else: l.append(int(i))
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,661
s623596758
p00013
u777299405
1448432231
Python
Python3
py
Accepted
20
7532
131
stack = [] while True: try: n = int(input()) except: break stack.append(n) if n else print(stack.pop())
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,662
s399878427
p00013
u461370825
1449737266
Python
Python
py
Accepted
10
6232
147
res = [] while True: try: n = input() if n == 0: print res[len(res)-1] res = res[:-1] else: res.append(n) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,663
s733587743
p00013
u560214129
1450506034
Python
Python3
py
Accepted
20
7580
184
import sys x=[] u=[] for line in sys.stdin.readlines(): y=int(line) if(y!=0): x.append(y) else: u.append(x.pop(-1)) for i in range(len(u)): print(u[i])
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,664
s704681263
p00013
u825618558
1451512209
Python
Python3
py
Accepted
30
7532
194
import sys lines = sys.stdin.readlines() queue = [] for line in lines: if int(line)>0: queue.append(int(line)) elif int(line)==0: print (queue[-1]) queue.pop(-1)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,665
s230114530
p00013
u463990569
1452847022
Python
Python3
py
Accepted
20
7608
167
garage = [] while True: try: car = int(input()) except: break if car == 0: print(garage.pop()) else: garage.append(car)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,666
s421999523
p00013
u580607517
1453044326
Python
Python
py
Accepted
10
6268
139
try: rail = [] while True: n = int(raw_input()) if n != 0: rail.append(n) else: print rail.pop() except: pass
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,667
s375676032
p00013
u512342660
1455278220
Python
Python
py
Accepted
10
6376
203
import sys carslist = [] anslist = [] for line in sys.stdin: n = int(line) if n == 0: anslist.append(carslist.pop()) else: carslist.append(n) for ans in anslist: print ans
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,668
s055979035
p00013
u648595404
1457503592
Python
Python3
py
Accepted
30
7544
136
import sys cars = [] for line in sys.stdin: car = int(line) if car: cars.append(car) else: print(cars.pop())
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,669
s505267957
p00013
u650459696
1458397847
Python
Python3
py
Accepted
20
7552
165
import sys stk = [] ans = [] for i in sys.stdin: if(int(i)==0): ans.append(stk.pop()) else: stk.append(int(i)) print('\n'.join(map(str,ans)))
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,670
s277246288
p00013
u148101999
1458863687
Python
Python
py
Accepted
20
6336
332
#encoding=utf-8 stac, car_in, ans = [], [], [] while True: try: stac.append(input()) except: break z = len(stac) for i in xrange(z): if stac[i] != 0: car_in.insert(0,stac[i]) elif stac[i] == 0: ans.append(car_in[0]) del car_in[0] for i in xrange(len(ans)): print ans[i]
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,671
s225050851
p00013
u075836834
1458938618
Python
Python3
py
Accepted
20
7496
132
A=[] while True: try: num=int(input()) if num==0: print(A[-1]) A.pop() else: A.append(num) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,672
s348738537
p00013
u966364923
1459426125
Python
Python3
py
Accepted
20
7544
138
import sys stack = [] for line in sys.stdin: a = int(line) if a == 0: print(stack.pop()) else: stack.append(a)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,673
s769538977
p00013
u130979865
1459923781
Python
Python
py
Accepted
10
6428
163
# -*- coding: utf-8 -*- import sys stack = [] for line in sys.stdin: n = int(line) if n == 0: print stack.pop() else: stack.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,674
s425743769
p00013
u572790226
1460292994
Python
Python3
py
Accepted
20
7312
171
import sys orders = sys.stdin.readlines() stack = [] for order in orders: if order == '0\n': print(stack.pop(), end = '') else: stack.append(order)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,675
s570392058
p00013
u529386725
1461620894
Python
Python3
py
Accepted
30
7512
150
li = [] while True: try: x = int(input()) except: break if x == 0: print(li.pop()) else: li.append(x)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,676
s687218260
p00013
u894114233
1461767616
Python
Python
py
Accepted
10
6212
160
train=[] while 1: try: n=input() if n==0: print(train.pop()) else: train.append(n) except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,677
s047639059
p00013
u744114948
1465016396
Python
Python3
py
Accepted
20
7604
150
a = [] while True: try: s = int(input()) except: break if s != 0: a.append(s) else: print(a.pop())
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,678
s204408054
p00013
u957021485
1465613048
Python
Python3
py
Accepted
20
7628
192
import sys lst = [int(line) for line in sys.stdin.readlines()] queue = [] for num in lst: if num != 0: queue.append(num) else: print(queue[-1]) del queue[-1]
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,679
s266201049
p00013
u766477342
1466378077
Python
Python3
py
Accepted
30
7572
149
try: l = [] while 1: d = int(input()) if d: l.append(d) else: print(l.pop()) except: pass
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,680
s572526600
p00013
u811773570
1466553278
Python
Python3
py
Accepted
20
7620
142
a = [] while True: try: i = int(input()) except: break if i == 0: c = a.pop() print(c) else: a.append(i)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,681
s320985777
p00013
u896025703
1469329247
Python
Python
py
Accepted
10
6348
185
import sys stack = [] for i in sys.stdin: try: a = int(i) if a > 0: stack.append(a) else: print stack.pop() except: pass
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,682
s352777268
p00013
u146816547
1469679752
Python
Python
py
Accepted
10
6272
159
stack = [] while True: try: s = int(raw_input()) if s == 0: print stack.pop() else: stack.append(s) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,683
s135918984
p00013
u582608581
1470815262
Python
Python3
py
Accepted
30
7348
146
stack = list() while True: try: num = eval(input()) if num != 0: stack.append(num) else: print(stack.pop()) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,684
s192019467
p00013
u358919705
1471861900
Python
Python3
py
Accepted
20
7648
182
cars = [] while True: try: num = int(input()) except: break if num == 0: print(cars[-1]) cars[-1:] = [] else: cars.append(num)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,685
s422915092
p00013
u589886885
1471955004
Python
Python3
py
Accepted
20
7448
135
import sys a = [] for i in sys.stdin.readlines(): n = i[:-1] if n == '0': print(a.pop()) else: a.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,686
s538361034
p00013
u379499530
1472778616
Python
Python
py
Accepted
10
6224
137
rail = [] while 1: try: n = input() if n > 0: rail.append(n) else: print rail.pop() except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,687
s049360517
p00013
u393305246
1474277972
Python
Python
py
Accepted
10
6364
197
import sys import sys a = [] for line in sys.stdin: a.append(line) lis=[] for n in a: inp=int(n) if inp==0: print lis[-1] del lis[-1] else: lis.append(inp)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,688
s222976081
p00013
u776559258
1477562825
Python
Python3
py
Accepted
20
7528
199
# coding: utf-8 L=[] while True: try: n=int(input()) if n==0: print(L[-1]) L.pop() else: L.append(n) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,689
s356217526
p00013
u659302741
1477763027
Python
Python3
py
Accepted
20
7568
139
import sys stack = [] for line in sys.stdin: n = int(line) if n == 0: print(stack.pop()) else: stack.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,690
s566558465
p00013
u252368621
1479003634
Python
Python3
py
Accepted
20
7544
156
import sys s=[] while True: try: n=int(input()) except: sys.exit() if n==0: print(s.pop()) else: s.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,691
s074259624
p00013
u660912567
1479269362
Python
Python3
py
Accepted
20
7508
121
import sys num_li = [] for line in sys.stdin: if int(line)==0: print(num_li.pop()) else: num_li.append(int(line))
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,692
s884289233
p00013
u922871577
1479281513
Python
Python
py
Accepted
10
6348
134
import sys s = [] for line in sys.stdin: if line.rstrip() == '0': print s.pop() else: s.append(line.rstrip())
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,693
s955608075
p00013
u175111751
1479318394
Python
Python3
py
Accepted
20
7584
158
stack = [] while True: try: n = int(input()) except: break if n == 0: print(stack.pop()) else: stack.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,694
s953677871
p00013
u301729341
1481013677
Python
Python3
py
Accepted
30
7484
184
Num = [] while True: try: n = int(input()) if n != 0: Num.append(n) elif n == 0: print(Num.pop()) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,695
s260456816
p00013
u123687446
1481109899
Python
Python3
py
Accepted
20
7588
155
s = [] while True: try: n = int(input()) except EOFError: break if n == 0: print(s.pop()) else: s.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,696
s534416113
p00013
u919202930
1481589930
Python
Python3
py
Accepted
20
7496
140
memory=[] while True: try: n=int(input()) except EOFError: break if n==0: print(memory.pop()) else: memory.append(n)
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,697
s378837892
p00013
u811733736
1481595537
Python
Python3
py
Accepted
30
7656
380
import sys from collections import deque if __name__ == '__main__': s = deque() # ?????????????????¢???????????¨?????????????????\??£???????????????append()??????????????????????????????pop() # ??????????????\?????¨??????????????? for line in sys.stdin: if line.strip() == '0': print(s.pop()) else: s.append(line.strip())
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,698
s037576748
p00013
u546285759
1481612887
Python
Python3
py
Accepted
20
7532
220
cars = [] gone = [] while True: try: c = int(input()) if c != 0: cars.append(c) else: gone.append(cars.pop()) except: break print('\n'.join(map(str, gone)))
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,699
s354988038
p00013
u923668099
1482108219
Python
Python3
py
Accepted
20
7552
255
# coding: utf-8 # Here your code ! stack = [] while True: try: a = int(input()) if a == 0: print(stack[-1]) stack.pop() else: stack.append(a) except EOFError: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,700
s557609269
p00013
u661290476
1482206642
Python
Python3
py
Accepted
20
7580
171
tracks=[] while True: try: s=int(input()) if s==0: print(tracks.pop()) else: tracks.append(s) except: break
p00013
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
1 6 0 8 10 0 0 0
6 10 8 1
5,701