submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s600517701
p00012
Runtime Error
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0]) while True: t=input() if t=="":break l=[float(i) for i in t.split()] ba=[l[0]-l[2],l[1]-l[3]] ab=[-i for i in ba] cb=[l[2]-l[4],l[3]-l[5]] bc=[-i for i in cb] ca=[l[0]-l[4],l[1]-l[5]] ac=[-i for i in ca] ap=[l[6]-l[0],l[7]-l[1]] bp=[l[6]-l[2],l[7]-l[3]] cp=[l[6]-l[4],l[7]-l[5]] if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp): print("NO") else: print("YES")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s736066125
p00012
Runtime Error
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0]) while True: t=input() if t=="":break l=[float(i) for i in t.split()] ba=[l[0]-l[2],l[1]-l[3]] ab=[-i for i in ba] cb=[l[2]-l[4],l[3]-l[5]] bc=[-i for i in cb] ca=[l[0]-l[4],l[1]-l[5]] ac=[-i for i in ca] ap=[l[6]-l[0],l[7]-l[1]] bp=[l[6]-l[2],l[7]-l[3]] cp=[l[6]-l[4],l[7]-l[5]] if 0: print("NO") else: print("YES")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s744238328
p00012
Runtime Error
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0]) while True: t=input() if t=="": break l=[float(i) for i in t.split()] ba=[l[0]-l[2],l[1]-l[3]] ab=[-i for i in ba] cb=[l[2]-l[4],l[3]-l[5]] bc=[-i for i in cb] ca=[l[0]-l[4],l[1]-l[5]] ac=[-i for i in ca] ap=[l[6]-l[0],l[7]-l[1]] bp=[l[6]-l[2],l[7]-l[3]] cp=[l[6]-l[4],l[7]-l[5]] if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp) or g(ca,cb)<g(ca,cp): print("NO") else: print("YES")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s578061499
p00012
Runtime Error
import sys def cross(a,b,p): return ((b[0]-a[0])*(p[1]-a[1])) - ((p[0]-a[0])*(b[1]-a[1])) for i in sys.stdin.readlines(): l = [float(x) for x in i.split()] a,b,c,p = [l[:2],l[2:4],l[4:6],l[6:]] if cross(a,b,p)<=0 and cross(b,c,p)<=0 and cross(c,a,p)<=0 : print "YES" elif cross(a,b,p)>=0 and cross(b,c,p)>=0 and cross(c,a,p)>=0 : print "YES" else: print "N0"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s670284173
p00012
Runtime Error
import sys def cross(a,b,p): return ((b[0]-a[0])*(p[1]-a[1])) - ((p[0]-a[0])*(b[1]-a[1])) for i in sys.stdin: l = [float(x) for x in i.split()] a,b,c,p = [l[:2],l[2:4],l[4:6],l[6:]] if cross(a,b,p)<=0 and cross(b,c,p)<=0 and cross(c,a,p)<=0 : print "YES" elif cross(a,b,p)>=0 and cross(b,c,p)>=0 and cross(c,a,p)>=0 : print "YES" else: print "N0"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s772048376
p00012
Runtime Error
import sys def cross(a, b): return (a.conjugate() * b).real def dot(a, b): return (a.conjugate() * b).imag def ccw(a, b, c): x = b - a y = c - a; if cross(x, y) > 0: return 1 if cross(x, y) < 0: return -1 if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = ccw(l[0][0], l[0][1], p) x = int(x / abs(x)) for i in l[1:]: y = ccw(i[0], i[1], p) y = int(y / abs(y)) if x != y: print "NO" return print 'YES' for line in sys.stdin: ax, ay, bx, by, cx, cy, px, py = map(float, line.split()) a = complex(ax, ay) b = complex(bx, by) c = complex(cx, cy) p = complex(px, py) solve([(a, b), (b, c), (c, a)], p)
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s114968465
p00012
Runtime Error
import sys def cross(a, b): return (a.conjugate() * b).real def dot(a, b): return (a.conjugate() * b).imag def ccw(a, b, c): x = b - a y = c - a; if cross(x, y) > 0: return 1 if cross(x, y) < 0: return -1 if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = ccw(l[0][0], l[0][1], p) if x != 0: x = int(x / abs(x)) for i in l[1:]: y = ccw(i[0], i[1], p) if y != 0: y = int(y / abs(y)) if x != y: print "NO" return print 'YES' for line in sys.stdin: ax, ay, bx, by, cx, cy, px, py = map(float, line.split()) a = complex(ax, ay) b = complex(bx, by) c = complex(cx, cy) p = complex(px, py) solve([(a, b), (b, c), (c, a)], p)
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s012715801
p00012
Runtime Error
import sys for line in sys.stdin: list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)] sorted(cross) if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0): print "YES" else: print "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s079557232
p00012
Runtime Error
import sys for line in sys.stdin.readlines(): list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)] sorted(cross) if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0): print "YES" else: print "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s055599028
p00012
Runtime Error
import sys for line in sys.stdin.readlines(): list=map(float,line.split(" ")) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)] sorted(cross) if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0): print "YES" else: print "NO"
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s869722286
p00012
Runtime Error
#coding: utf-8 def isInOut(p, q, s, c, z): if (p*c[0] + q*c[1] - s)*(p*z[0] + q*z[1] - s) > 0: return True else: return False while 1: try: x = [0 for i in xrange(3)] y = [0 for i in xrange(3)] c = [0 for i in xrange(2)] z = [0 for i in xrange(2)] a,b,t = [[0 for i in xrange(2)] for i in xrange(3)] p,q,s = [[0 for i in xrange(3)] for i in xrange(3)] x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split()) c = [sum(x)/3, sum(y)/3] for j in xrange(3): if x[j] == x[j-1]: p[j] = 1. q[j] = 0. s[j] = x[j] else: t[j] = (y[j] - y[j-1]) / (x[j] - x[j-1]) p[j] = t[j] q[j] = -1. s[j] = t[j]*x[j]-y[j] #print p[j], q[j], s[j] if isInOut(p[j], q[j], s[j], c, z) is False: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s690031725
p00012
Runtime Error
#coding: utf-8 def isInOut(p, q, s, c, z): if (p*c[0] + q*c[1] - s)*(p*z[0] + q*z[1] - s) > 0: return True else: return False while 1: try: x = [0 for i in xrange(3)] y = [0 for i in xrange(3)] c = [0 for i in xrange(2)] z = [0 for i in xrange(2)] t = [0 for i in xrange(3)] p,q,s = [[0 for i in xrange(3)] for i in xrange(3)] x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split()) c = [sum(x)/3, sum(y)/3] for j in xrange(3): if x[j] == x[j-1]: p[j] = 1. q[j] = 0. s[j] = x[j] else: t[j] = (y[j] - y[j-1]) / (x[j] - x[j-1]) p[j] = t[j] q[j] = -1. s[j] = t[j]*x[j]-y[j] #print p[j], q[j], s[j] if isInOut(p[j], q[j], s[j], c, z) is False: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s819824163
p00012
Runtime Error
#coding: utf-8 def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x,y = [[0 for i in xrange(3)] for j in xrange(2)] a = [] z = [0 for i in xrange(2)] x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split()) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s404757191
p00012
Runtime Error
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x,y = [[0 for i in xrange(3)] for j in xrange(2)] a = [] z = [0 for i in xrange(2)] x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split()) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s630839477
p00012
Runtime Error
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x,y = [[0 for i in range(3)] for j in range(2)] a = [] z = [0 for i in range(2)] x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split()) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s277764634
p00012
Runtime Error
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) def main(): while 1: try: x,y = [[0. for i in xrange(3)] for j in xrange(2)] a = [] z = [0. for i in xrange(2)] x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split()) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break if __name__ == '__main__': main()
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s905289987
p00012
Runtime Error
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x1,y1,x2,y2,x3,y3 = (0,0,0,0,0,0) a = [] xp,yp = (0,0) x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a.append(x1+(y1)*1j) a.append(x2+(y2)*1j) a.append(x3+(y3)*1j) c = (x1+x2+x3)/3+((y1+y2+y3)/3)*1j p = xp+yp*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s198977166
p00012
Runtime Error
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x,y = [[0. for i in xrange(3)] for j in xrange(2)] a = [] xp,yp = (0,0) line = raw_input().split() if line == []: break x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, line) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s015594002
p00012
Runtime Error
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x,y = [[0. for i in xrange(3)] for j in xrange(2)] a = [] z = (0,0) line = raw_input().split() if line == []: break x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, line) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s647870759
p00012
Runtime Error
def heron(a,b,c): s = 0.5*(a+b+c) return (s*(s-a)*(s-b)*(s-c))**0.5 while True: try: x = map(float, raw_input().split(' ')) ab = ((x[0]-x[2])**2 +(x[1]-x[3])**2)**0.5 bc = ((x[2]-x[4])**2 +(x[3]-x[5])**2)**0.5 ca = ((x[4]-x[0])**2 +(x[5]-x[1])**2)**0.5 area_abc = heron(ab,bc,ca) oa = ((x[0]-x[6])**2 +(x[1]-x[7])**2)**0.5 ob = ((x[2]-x[6])**2 +(x[3]-x[7])**2)**0.5 oc = ((x[4]-x[6])**2 +(x[5]-x[7])**2)**0.5 area_oab = heron(ab,oa,ob) area_obc = heron(bc,ob,oc) area_oca = heron(ca,oc,oa) area_sum = area_oab+area_obc+area_oca if round(area_abc,2) < round(area_sum,2): print 'NO' else: print 'YES' except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s761217174
p00012
Runtime Error
def heron(a,b,c): s = 0.5*(a+b+c) return (s*(s-a)*(s-b)*(s-c))**0.5 while True: try: x = map(float, raw_input().split(' ')) ab = ((x[0]-x[2])**2 +(x[1]-x[3])**2)**0.5 bc = ((x[2]-x[4])**2 +(x[3]-x[5])**2)**0.5 ca = ((x[4]-x[0])**2 +(x[5]-x[1])**2)**0.5 area_abc = heron(ab,bc,ca) oa = ((x[0]-x[6])**2 +(x[1]-x[7])**2)**0.5 ob = ((x[2]-x[6])**2 +(x[3]-x[7])**2)**0.5 oc = ((x[4]-x[6])**2 +(x[5]-x[7])**2)**0.5 area_oab = heron(ab,oa,ob) area_obc = heron(bc,ob,oc) area_oca = heron(ca,oc,oa) area_sum = area_oab+area_obc+area_oca if round(area_abc) < round(area_sum): print 'NO' else: print 'YES' except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s099534444
p00012
Runtime Error
while True: try: x1,y1,x2,y2,x3,y3,px,py = map(float,raw_input().split(' ')) v1 = [x1-px,y1-py] v2 = [x2-px,y2-py] v3 = [x3-px,y3-py] v12 =[v1[0]+v2[0],v1[1]+v2[1]] if v12[0]*v3[0]+v12[1]*v3[1] < 0: print 'YES' else: print 'NO' except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s968082055
p00012
Runtime Error
while True: try: x1,y1,x2,y2,x3,y3,px,py = map(float,raw_input().split(' ')) v1 = [x1-px,y1-py] v2 = [x2-px,y2-py] v3 = [x3-px,y3-py] v12 =[v1[0]+v2[0],v1[1]+v2[1]] if v12[0]*v3[0]+v12[1]*v3[1] < 0: print 'YES' else: print 'NO' except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s626502958
p00012
Runtime Error
while True: try: x1,y1,x2,y2,x3,y3,px,py = map(float,raw_input().split()) v1 = [x1-px,y1-py] v2 = [x2-px,y2-py] v3 = [x3-px,y3-py] v12 =[v1[0]+v2[0],v1[1]+v2[1]] if v12[0]*v3[0]+v12[1]*v3[1] < 0: print 'YES' else: print 'NO' except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s652883535
p00012
Runtime Error
def checker(x1,y1,x2,y2,xp,yp): vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: return 1 elif vec < 0: return -1 while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) except EOFError: break r = checker(x1,y1,x2,y2,xp,yp) r += checker(x2, y2, x3, y3, xp, yp) r += checker(x3, y3, x1, y1, xp, yp) if r == 3 or r == -3: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s952262433
p00012
Runtime Error
def checker(x1,y1,x2,y2,xp,yp): vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: return 1 elif vec < 0: return -1 while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = checker(x1,y1,x2,y2,xp,yp) r += checker(x2, y2, x3, y3, xp, yp) r += checker(x3, y3, x1, y1, xp, yp) if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s089369479
p00012
Runtime Error
global r def checker(x1,y1,x2,y2,xp,yp): vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: return 1 elif vec < 0: return -1 while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 r = r + checker(x1,y1,x2,y2,xp,yp) r = r + checker(x2, y2, x3, y3, xp, yp) r = r + checker(x3, y3, x1, y1, xp, yp) if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s591932173
p00012
Runtime Error
global r def checker(x1,y1,x2,y2,xp,yp): vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: return int(1) elif vec < 0: return int(-1) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 r += checker(x1,y1,x2,y2,xp,yp) print r r += checker(x2, y2, x3, y3, xp, yp) print r r += checker(x3, y3, x1, y1, xp, yp) print r if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s015256381
p00012
Runtime Error
global r def checker(x1,y1,x2,y2,xp,yp): vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: return int(1) elif vec < 0: return int(-1) if __name__ == '__main__': while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 r += checker(x1,y1,x2,y2,xp,yp) r += checker(x2, y2, x3, y3, xp, yp) r += checker(x3, y3, x1, y1, xp, yp) if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s319878761
p00012
Runtime Error
global r def checker(x1,y1,x2,y2,xp,yp): vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: return int(1) elif vec < 0: return int(-1) if __name__ == '__main__': while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 r += int(checker(x1,y1,x2,y2,xp,yp)) r += int(checker(x2, y2, x3, y3, xp, yp)) r += int(checker(x3, y3, x1, y1, xp, yp)) if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s336716975
p00012
Runtime Error
def checker(x1,y1,x2,y2,xp,yp): r = 0 vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: r = 1 return r elif vec < 0: r = -1 return r if __name__ == '__main__': while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 r += int(checker(x1,y1,x2,y2,xp,yp)) r += int(checker(x2, y2, x3, y3, xp, yp)) r += int(checker(x3, y3, x1, y1, xp, yp)) if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s921932213
p00012
Runtime Error
while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a = (x1-x2)**2+(y1-y2)**2 b = (x1-x3)**2+(y1-y3)**2 c = (x2-x3)**2+(y2-y3)**2 xa = (x3-xp)**2+(y3-yp)**2 xb = (x2-xp)**2+(y2-yp)**2 xc = (x1-xp)**2+(y1-yp)**2 cosa = (a-b+c)/(2*math.sqrt(b)*math.sqrt(c)) cosb = (b-a+c)/(2*math.sqrt(a)*math.sqrt(c)) cosc = (c-a+b)/(2*math.sqrt(a)*math.sqrt(b)) cos1 = (xc-xa+xc)/(2*math.sqrt(xa)*math.sqrt(b)) cos2 = (xa-c+xb)/(2*math.sqrt(xb)*math.sqrt(c)) cos3 = (xb-a+xc)/(2*math.sqrt(xc)*math.sqrt(a)) # cos4 = (a-b+c)/(2*math.sqrt(xa)*math.sqrt(c)) # cos5 = (a-b+c)/(2*math.sqrt(xb)*math.sqrt(a)) # cos6 = (a-b+c)/(2*math.sqrt(xc)*math.sqrt(b)) if cos1<cosa or cos2<cosb or cos3<cosc: print "YES" print "YES" else: print "NO" except: break
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. </p> <p> Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not. </p> <!-- <p> You can suppose that P is never on the points nor sides of the triangle. </p> --> <H2>Input</H2> <p> Input consists of several datasets. Each dataset consists of:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/> </p> <p> All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100. </p> <h2>Constraints</h2> <p> You can assume that: </p> <ul> <li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li> <li>1.0 $\leq$ Length of each side of a tringle</li> <li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li> </ul> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s401489486
p00013
Wrong Answer
stack = [] while True: try: n = int(input) except: break stack.append(n) if n else print(stack.pop())
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s507949972
p00013
Wrong Answer
garage = [] cars = [] while True: num = int(input()) if num == 0: cars.append(garage.pop()) else: garage.append(num) print(garage) if not garage: break [print(car) for car in cars]
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s177508831
p00013
Wrong Answer
garage = [] cars = [] while True: num = int(input()) if num == 0: cars.append(garage.pop()) else: garage.append(num) if not garage: break [print(car) for car in cars]
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s848220816
p00013
Wrong Answer
garage = [] while True: num = int(input()) if num == 0: print(garage.pop()) else: garage.append(num) if not garage: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s806160553
p00013
Wrong Answer
rail = [] while True: n = int(raw_input()) if n != 0: rail.append(n) else: print rail.pop() if len(rail) == 0: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s888098144
p00013
Wrong Answer
stack = [] while True: a = int(input()) if a == 0: print(stack.pop()) else: stack.append(a) if len(stack) == 0: exit()
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s896913881
p00013
Wrong Answer
li = [] li.append(int(input())) depth = 1 while depth > 0: x = int(input()) if x == 0: print(li.pop()) depth -= 1 else: li.append(x) depth += 1
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s005032870
p00013
Wrong Answer
a = [] while True: s = int(input()) if s != 0: a.append(s) else: print(a.pop()) if len(a) == 0: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s941533006
p00013
Wrong Answer
lis=[] lis.append(input()) while lis!=[]: inp=input() if inp==0: print lis[-1] del lis[-1] else: lis.append(inp)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s718347695
p00013
Wrong Answer
# coding: utf-8 L=[] while True: try: n=int(input()) if n==0: L.pop() else: L.append(n) except EOFError: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s255813768
p00013
Wrong Answer
s=[int(input())] while(len(s)!=0): n=int(input()) if n==0: print(s.pop()) else: s.append(n)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s599832397
p00013
Wrong Answer
list = {} while True: try: num = int(input()) if num == 0: print(list.pop()) else: list.append(num) except: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s893804286
p00013
Wrong Answer
stack = [] stack.append(int(input())) while stack: inp = int(input()) if inp == 0: a = stack[-1] del stack[-1] print(a) else: stack.append(inp)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s933992542
p00013
Wrong Answer
stack = [] stack.append(int(input())) ans= [] while stack: inp = int(input()) if inp == 0: a = stack[-1] del stack[-1] ans.append(a) else: stack.append(inp) print(*ans, sep="\n")
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s737626190
p00013
Wrong Answer
# coding:utf-8 syako = [] try: while True: number = int(raw_input()) if number != 0: syako.append(number) elif number == 0: print syako.pop() number = int(raw_input()) except: pass
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s370085582
p00013
Wrong Answer
i= 0 a,b = [],[] while True: try: a.append(int(raw_input())) #print a if a[i] == 0: b.append(a[i-1]) a.pop() a.pop() i -=1 else: i +=1 if len(a)== 0: break else: continue except: #print "bbbbbbbb" break for k in range(0,len(b)): print b[k]
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s043046276
p00013
Wrong Answer
i= 0 a,b = [],[] while True: try: a.append(int(raw_input())) #print a if a[i] == 0: b.append(a[i-1]) a.pop() #print i print a[i-1] a.pop() i -=1 else: i +=1 if len(a)== 0: break else: continue except: #print "bbbbbbbb" break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s087884712
p00013
Wrong Answer
i= 0 a,b = [],[] while True: try: a.append(int(raw_input())) if a[i] == 0: b.append(a[i-1]) a.pop() print a[i-1] a.pop() i -=1 else: i +=1 if len(a)== 0: break else: continue except: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s394881131
p00013
Wrong Answer
a=[] while 1: try:n=int(input());a.append(e)if e else print(a.pop()) except:break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s064244293
p00013
Wrong Answer
import sys a=[map(int,i)for i in sys.stdin] b=[] print(a) for j in a: if j == 0: print(b.pop()) else: b.append(j)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s516228372
p00013
Wrong Answer
import sys a=[int(i)for i in sys.stdin] b=[] print(a) for j in a: if j == 0: print(b.pop()) else: b.append(j)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s479462873
p00013
Wrong Answer
import sys a=[map(int,i)for i in sys.stdin] b=[] for j in a: if j == 0: print(b.pop()) else: b.append(j)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s897857686
p00013
Wrong Answer
import sys a=[int(i)for i in sys.stdin] b=[] print(a) for j in a: if j == 0: print(b.pop()) else: b.append(j)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s480664496
p00013
Wrong Answer
l=[] l.append(int(input())) while l: o=int(input()) if not o: print(l.pop()) else: l.append(o)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s245975988
p00013
Wrong Answer
l=[] r=[] l.append(int(input())) while l: o=int(input()) if not o: r.append(l.pop()) else: l.append(o) for i in r: print(i)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s016158094
p00013
Wrong Answer
tracks = [] while 1: try: c = int(raw_input()) if c == 0: print tracks.pop() if tracks == []: break else: tracks.append(c) except EOFError: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s257609431
p00013
Wrong Answer
garage = [] while True: came = int(raw_input()) if came == 0: print garage[-1] garage.pop(-1) if len(garage) == 0: break else: garage.append(came)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s635271917
p00013
Wrong Answer
from collections import deque garage = deque() while True: came = int(raw_input()) if came == 0: print garage.pop() if len(garage) == 0: break else: garage.append(came)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s448833464
p00013
Wrong Answer
l = [] while True: train = int(raw_input()) if train == 0: print(l.pop()) else: l.append(train) if l == []: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s643248060
p00013
Wrong Answer
d = [] while 1: n = int(raw_input()) if n == 0: print d[-1] d = d[:-1] else: d.append(n) if len(d) == 0: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s762817941
p00013
Wrong Answer
n = int(raw_input()) stuck = "" for i in range(n): x = raw_input() if x == "0": l = len(stuck) - 1 print stuck[l] stuck = stuck[:l] else: stuck += x
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s382170234
p00013
Wrong Answer
n = int(raw_input()) stuck = "" count = 0 while count < n: x = raw_input() if x == "0": l = len(stuck) - 1 print stuck[l] stuck = stuck[:l] else: stuck += x count += 1
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s910162320
p00013
Wrong Answer
stuck = "" count = 0 while True: try: x = raw_input() if x == "0": l = len(stuck) - 1 print stuck[l] stuck = stuck[:l] else: stuck += x count += 1 except: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s703592948
p00013
Accepted
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()
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s325857017
p00013
Accepted
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
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s987365887
p00013
Accepted
train = [] while True: try: n = int(raw_input()) if n == 0: print train.pop() else: train.append(n) except: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s636846046
p00013
Accepted
st = [] while 1: try: x = int(input()) st.append(x) if x != 0 else print(st.pop()) except EOFError: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s452053224
p00013
Accepted
stack = [] while True: try: data = int(input()) if data == 0: print stack.pop() else: stack.append(data) except: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s380117728
p00013
Accepted
# -*- 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
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s659723291
p00013
Accepted
#!/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)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s245779858
p00013
Accepted
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
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s361353078
p00013
Accepted
import sys cars = [] for line in sys.stdin: car = int(line) if car: cars.append(car) else: print(cars.pop())
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s038827168
p00013
Accepted
stack = list() while (True): try: s = int(input()) except EOFError: break; if s == 0: print(stack.pop()) else: stack.append(s)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s444065889
p00013
Accepted
ls = [] while 1: try: n = int(raw_input()) except EOFError: break if n!=0: ls.append(n) else: print ls[-1] del ls[-1]
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s206060020
p00013
Accepted
import sys Rail = [] for S in sys.stdin: S=int(S) if S!=0: Rail.append(S) else: print Rail.pop()
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s413827069
p00013
Accepted
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)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s542874524
p00013
Accepted
ls = [] while True: try: n = int(raw_input()) except EOFError: break if n != 0: ls.append(n) else: print ls.pop()
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s304110628
p00013
Accepted
import sys s=[] for l in sys.stdin: n=int(l) if n==0:print s.pop() else:s.append(n)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s188912840
p00013
Accepted
import sys s=[] for n in map(int,sys.stdin): if n==0:print s.pop() else:s.append(n)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s144528387
p00013
Accepted
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)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s469307955
p00013
Accepted
#!/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)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s971684499
p00013
Accepted
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]
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s372937634
p00013
Accepted
#!/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()
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s862893564
p00013
Accepted
# -*- 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()
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s310853044
p00013
Accepted
import sys l = [] for i in sys.stdin.readlines(): if int(i) == 0: print(l.pop()) else: l.append(int(i))
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s623596758
p00013
Accepted
stack = [] while True: try: n = int(input()) except: break stack.append(n) if n else print(stack.pop())
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s399878427
p00013
Accepted
res = [] while True: try: n = input() if n == 0: print res[len(res)-1] res = res[:-1] else: res.append(n) except EOFError: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s733587743
p00013
Accepted
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])
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s704681263
p00013
Accepted
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)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s230114530
p00013
Accepted
garage = [] while True: try: car = int(input()) except: break if car == 0: print(garage.pop()) else: garage.append(car)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s421999523
p00013
Accepted
try: rail = [] while True: n = int(raw_input()) if n != 0: rail.append(n) else: print rail.pop() except: pass
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s375676032
p00013
Accepted
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
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s055979035
p00013
Accepted
import sys cars = [] for line in sys.stdin: car = int(line) if car: cars.append(car) else: print(cars.pop())
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s505267957
p00013
Accepted
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)))
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s277246288
p00013
Accepted
#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]
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s225050851
p00013
Accepted
A=[] while True: try: num=int(input()) if num==0: print(A[-1]) A.pop() else: A.append(num) except EOFError: break
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s348738537
p00013
Accepted
import sys stack = [] for line in sys.stdin: a = int(line) if a == 0: print(stack.pop()) else: stack.append(a)
1 6 0 8 10 0 0 0
6 10 8 1
<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>
s769538977
p00013
Accepted
# -*- coding: utf-8 -*- import sys stack = [] for line in sys.stdin: n = int(line) if n == 0: print stack.pop() else: stack.append(n)
1 6 0 8 10 0 0 0
6 10 8 1
<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>