submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s280956239
p00021
Runtime Error
class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y def __sub__(left, right): return Point(left.x - right.x, left.y - right.y) #cross def __mul__(left, right): return left.x * right.y - left.y * right.x while True: try: (x1, y1, x2, y2, x3, y3, x4, y4) = [int(i) for i in raw_input().split()] except EOFError: break a = Point(x1, y1) b = Point(x2, y2) c = Point(x3, y3) d = Point(x4, y4) ab = a - b cd = c - d if(a * b == 0): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s658805237
p00021
Runtime Error
class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y def __sub__(left, right): return Point(left.x - right.x, left.y - right.y) #cross def __mul__(left, right): return left.x * right.y - left.y * right.x for i in range(int(raw_input())): (x1, y1, x2, y2, x3, y3, x4, y4) = [int(i) for i in raw_input().split()] a = Point(x1, y1) b = Point(x2, y2) c = Point(x3, y3) d = Point(x4, y4) ab = a - b cd = c - d if(a * b == 0): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s097537365
p00021
Runtime Error
class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y def __sub__(left, right): return Point(left.x - right.x, left.y - right.y) #cross def __mul__(left, right): return left.x * right.y - left.y * right.x for i in range(int(raw_input())): (x1, y1, x2, y2, x3, y3, x4, y4) = [float(i) for i in raw_input().split()] a = Point(x1, y1) b = Point(x2, y2) c = Point(x3, y3) d = Point(x4, y4) ab = a - b cd = c - d if(a * b == 0.0): print 'YES' elif(a * (Point - b) == 0.0): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s946208750
p00021
Runtime Error
for i in range(int(input())): x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split()) a1 = (y2-y1)/(x2-x1); a2 = (y4-y3)/(x4-x3) b1 = y1-(a1*x1) ; b2 = y3-(a2*x3) if a1 == a2: if b1 == b2: print "NO" else: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s693731778
p00021
Runtime Error
from __future__ import (absolute_import, division, print_function, unicode_literals) from sys import stdin def gradient(x1, y1, x2, y2): return (y1 - y2) / (x1 - x2) for n in xrange(int(stdin.readline())): p = [float(s) for s in stdin.readline().split()] if gradient(*p[:4]) == gradient(*p[4:]): print('YES') else: print('NO')
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s479900738
p00021
Runtime Error
for i in range(input()): x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split()) if x1==x2 and x3 ==x4: print "YES" else: if (y2-y1)/(x2-x1) ==(y4-y3)/(x4-x3): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s928690372
p00021
Runtime Error
for i in range(input()): x1, y1, x2, y2, x3, y3, x4, y4 = map(float,raw_input().split()) if x1 == x2 and x3 == x4: print "YES" else: if (y1-y2)/(x1-x2) == (y3-y4)/(x3-x4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s340914048
p00021
Runtime Error
n = input() + 1 for val in range(1,n): x = map(float,raw_input().split(' ')) if (x[0]-x[2])/(x[1]-x[3]) == (x[4]-x[6])/(x[5]-x[7]): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s986505848
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x1 == x2: return x3 == x4 elif y1 == y2: return y3 == y4 else: return (y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3) #input_file = open(sys.argv[1], "r") #lines = input_file.readlines() lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s038439536
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x1 == x2 or x3 == x4: return x1 == x2 and x3 == x4 elif y1 == y2: return y3 == y4 else: return (y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3) #input_file = open(sys.argv[1], "r") #lines = input_file.readlines() lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s269586405
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x1 == x2 or x3 == x4: return x1 == x2 and x3 == x4 # elif y1 == y2: # return y3 == y4 else: return (y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3) #input_file = open(sys.argv[1], "r") #lines = input_file.readlines() lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s316476090
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x1 == x2 or x3 == x4: return x1 == x2 and x3 == x4 # elif y1 == y2: # return y3 == y4 else: return ((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3)) #input_file = open(sys.argv[1], "r") #lines = input_file.readlines() lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s845839400
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x1 == x2 or x3 == x4: return x1 == x2 and x3 == x4 elif y1 == y2 or y3 == y4: return y1 == y2 and y3 == y4 else: return ((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3)) #input_file = open(sys.argv[1], "r") #lines = input_file.readlines() lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s778685939
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x1 - x2 == 0.0 or x3 - x4 == 0.0: return x1 - x2 == 0.0 and x3 - x4 == 0.0 # elif y1 == y2 or y3 == y4: # return y1 == y2 and y3 == y4 else: return ((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3)) lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s380076980
p00021
Runtime Error
import sys def parallelism(x1, y1, x2, y2, x3, y3, x4, y4): if x2 - x1 == 0.0 or x4 - x3 == 0.0: return x2 - x1 == 0.0 and x4 - x3 == 0.0 else: return ((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3)) lines = sys.stdin.readlines() lines.pop(0) for line in lines: x1, y1, x2, y2, x3, y3, x4, y4 = tuple(map(float, line.split(' '))) if parallelism(x1, y1, x2, y2, x3, y3, x4, y4): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s284733952
p00021
Runtime Error
def cal(x1,y1,x2,y2): t = y1 - y2 v = x1 - x2 return t/v if __name__ == "__main__": a = int(raw_input()) for i in range(a): x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split(' ')) m1 = cal(x1,y1,x2,y2) m2 = cal(x3,y3,x4,y4) if m1 == m2: print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s992548162
p00021
Runtime Error
def cal(x1,y1,x2,y2): t = y1 - y2 v = x1 - x2 return t/v if __name__ == "__main__": a = int(raw_input()) for i in range(a): x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split(' ')) m1 = cal(x1,y1,x2,y2) m2 = cal(x3,y3,x4,y4) if (x1-x2) == 0 or (x3-x4) == 0: if (x1-x2) == 0 and (x3-x4) == 0: print 'YES' else: print 'NO' else: if m1 == m2: print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s670443180
p00021
Runtime Error
n = input()+1 for v in range(1,n): (x1,y1,x2,y2,x3,y3,x4,y4)=map(int,raw_input().split()) if x2-x1==0 or x4-x3==0: if x2-x1==0 and x4-x3==0: print "YES" else: print "NO" elif y2-y1==0 or y4-y3==0: if y2-y1==0 and y4-y3==0: print "YES" else: print "NO" else: a = (y2-y1)/(x2-x1) b = (y4-y3)/(x4-x3) if a == b: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s814776087
p00021
Runtime Error
n = input()+1 for v in range(1,n): (x1,y1,x2,y2,x3,y3,x4,y4)=map(int,raw_input().split()) if x2-x1==0 or x4-x3==0: if x2-x1==0 and x4-x3==0: print "YES" else: print "NO" elif y2-y1==0 or y4-y3==0: if y2-y1==0 and y4-y3==0: print "YES" else: print "NO" else: a = (y2-y1)/(x2-x1) b = (y4-y3)/(x4-x3) if a == b: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s931202117
p00021
Runtime Error
n = input()+1 for v in range(1,n): (x1,y1,x2,y2,x3,y3,x4,y4)=map(int,raw_input().split()) if x2-x1==0 or x4-x3==0: if x2-x1==0 and x4-x3==0: print "YES" else: print "NO" elif y2-y1==0 or y4-y3==0: if y2-y1==0 and y4-y3==0: print "YES" else: print "NO" else: if (y2-y1)/(x2-x1) == (y4-y3)/(x4-x3): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s910009508
p00021
Runtime Error
n = input()+1 for v in range(1,n): x=map(float,raw_input().split()) if x[2]-x[0]==0 and x[6]-x[4]==0: print "YES" elif x[2]-x[0]!=0 and x[6]-x[4]==0: print "NO" elif x[2]-x[0]==0 and x[6]-x[4]!=0: print "NO" else: if (y[3]-y[1])/(x[2]-x[0]) == (y[7]-y[5])/(x[6]-x[4]): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s567900746
p00021
Runtime Error
n = int(raw_input()) for i in range(n): d = [float(x) for x in raw_input().split()] if (d[2]-d[0])*(d[7]-d[5])==(d[3]-d[1])*(d[6]-d[4]): else: "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s757387542
p00021
Runtime Error
n = int(raw_input()) for i in range(n): x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split()) if (y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s454588586
p00021
Runtime Error
#!/usr/bin/python def main(): numData = int(raw_input()) count = 0 while count < numData: line = raw_input() coords = map(float, line.strip().split()) result = isParallel(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]) if result : print "YES" else: print "NO" count += 1 def isParallel(x1, y1, x2, y2, x3, y3, x4, y4): x1 = int(x1 * 100000) y1 = int(y1 * 100000) x2 = int(x2 * 100000) y2 = int(y2 * 100000) x3 = int(x3 * 100000) y3 = int(y3 * 100000) x4 = int(x4 * 100000) y4 = int(y4 * 100000) if (x2 == x1): return x4 == x3 else: return (y2 - y1)/(x2 - x1) == (y4 - y3)/(x4 - x3) main()
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s950140969
p00021
Runtime Error
import sys for s in sys.stdin: x1,y1,x2,y2,x3,y3,x4,y4 = map(float,s.split()) a = (y2-y1)/(x2-x1) b = (y4-y3)/(x4-x3) print 'YES' if a == b else 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s500374569
p00021
Runtime Error
for l in xrange(int(raw_input())): x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split()) a = (y2-y1)/(x2-x1) b = (y4-y3)/(x4-x3) print 'YES' if a == b else 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s911505356
p00021
Runtime Error
for i in xrange(int(raw_input())): x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split()) a = (y2-y1)/(x2-x1) b = (y4-y3)/(x4-x3) print 'YES' if a == b else 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s965218587
p00021
Runtime Error
n = int(raw_input()) for i in range(n): x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split()) a = (y2-y1)/(x2-x1) c = (y4-y3)/(x3-x1) if a == c: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s130110241
p00021
Runtime Error
n = int(raw_input()) for i in range(n): x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split()) a = (y2-y1)/(x2-x1) c = (y4-y3)/(x4-x3) if a == c: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s736972595
p00021
Runtime Error
n = int(raw_input()) for i in range(n): x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split()) a = (y2-y1)/(x2-x1) c = (y4-y3)/(x4-x3) if a == c: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s500232284
p00021
Runtime Error
import math n = int(raw_input()) for i in range(n): x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split()) if x2-x1==0.0 and x4-x3==0.0: print "YES" elif y2-y1==0.0 and y4-y3==0.0: print "YES" elif fabs((y2-y1)*(x4-x3) - (y4-y3)*(x2-x1))<0.000001: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s117063072
p00021
Runtime Error
import math n = int(raw_input()) for i in range(n): x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split()) if x2-x1==0.0 and x4-x3==0.0: print "YES" elif y2-y1==0.0 and y4-y3==0.0: print "YES" elif (y2-y1)*(x4-x3)/(y4-y3)/(x2-x1)==1.0: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s762854729
p00021
Runtime Error
import math N=range(int(raw_input())) for i in N: a,w,b,x,c,y,d,z=map(float, raw_input().split()) print ["NO","YES"][(w-x)*(c-d)=(y-z)*(a-b)]
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s846519728
p00021
Runtime Error
n = int(raw_input()) ans = [] for i in range(n): marks = map(float, raw_input().split()) AB = (marks[1] - marks[3]) / (marks[0] - marks[2]) CD = (marks[5] - marks[7]) / (marks[4] - marks[6]) if AB == CD: ans.append('YES') else: ans.append('NO') for s in ans: print s
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s538668369
p00021
Runtime Error
n = int(raw_input()) ans = [] for i in range(n): marks = map(float, raw_input().split()) AB = (marks[1] - marks[3]) / (marks[0] - marks[2]) CD = (marks[5] - marks[7]) / (marks[4] - marks[6]) if AB == CD: print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s013940981
p00021
Runtime Error
n = int(raw_input()) for i in range(n): marks = map(float, raw_input().split()) AB = (marks[1] - marks[3]) / (marks[0] - marks[2]) CD = (marks[5] - marks[7]) / (marks[4] - marks[6]) if AB == CD: print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s811928393
p00021
Runtime Error
for i in range(input()): ax,ay,bx,by,cx,cy,dx,dy = map(float, raw_input().split()) ab = (ay - by) / (ax - bx) cd = (cy - dy) / (cx - dx) if ab == cd: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s446438113
p00021
Runtime Error
for i in range(input()): ax,ay,bx,by,cx,cy,dx,dy = map(float, raw_input().split()) ab = (ay - by) / (ax - bx) cd = (cy - dy) / (cx - dx) if int(ab - cd) == 0: print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s634277835
p00021
Runtime Error
p = map( float, raw_input().split() ) flag = ( p[ 1 ] - p[ 0 ] ) * ( p[ 7 ] - p[ 6 ] ) == ( p[ 3 ] - p[ 2 ] ) * ( p[ 5 ] - p[ 4 ] ) print flag
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s261580858
p00021
Runtime Error
p = map( float, raw_input().split() ) flag = ( p[ 1 ] - p[ 0 ] ) * ( p[ 7 ] - p[ 6 ] ) == ( p[ 3 ] - p[ 2 ] ) * ( p[ 5 ] - p[ 4 ] ) print ( flag and 'YES' ) or 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s461689752
p00021
Runtime Error
n = int(raw_input) for i in range(n): p = map( float, raw_input().split() ) flag = ( p[ 1 ] - p[ 0 ] ) * ( p[ 7 ] - p[ 6 ] ) == ( p[ 3 ] - p[ 2 ] ) * ( p[ 5 ] - p[ 4 ] ) print ( flag and 'YES' ) or 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s112227274
p00021
Runtime Error
#include <stdio.h> #define ERROR_RANGE 0.000001 int main(void){ int cnt,flg; double x1,y1,x2,y2,x3,y3,x4,y4; scanf("%d",&cnt); while(cnt-- > 0){ scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4); if( (x1 - x2) < ERROR_RANGE || (x3 - x4) < ERROR_RANGE ){ flg = ((x1 - x2) < ERROR_RANGE && (x3 - x4) < ERROR_RANGE); }else{ flg = (x1 - x2)/(y1 - y2) - (x3 - x4)/(y3 - y4) < ERROR_RANGE; } if(flg){ puts("YES"); }else{ puts("NO"); } } return 0; }
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s400483308
p00021
Runtime Error
#include <stdio.h> #define ERROR_RANGE 0.000001 int main(void){ int cnt,flg; double x1,y1,x2,y2,x3,y3,x4,y4; scanf("%d",&cnt); while(cnt-- > 0){ scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4); if( (x1 - x2) < ERROR_RANGE || (x3 - x4) < ERROR_RANGE ){ flg = ((x1 - x2) < ERROR_RANGE && (x3 - x4) < ERROR_RANGE); }else{ flg = (x1 - x2)/(y1 - y2) - (x3 - x4)/(y3 - y4) < ERROR_RANGE; } if(flg){ puts("YES"); }else{ puts("NO"); } } return 0; }
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s735368184
p00021
Runtime Error
for i in range(input()): x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split()) if (x1 == x2 and x3 == x4) or (y1 == y2 and y3 == y4): print "YES" continue elif (y1-y2)/(x1-x2) == (y3-y4)/(x3-x4): print "YES" continue print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s087148415
p00021
Runtime Error
for i in range(input()): x1, y1, x2, y2, x3, y3, x4, y4 = map(lambda x: return "%f" % x, raw_input().split()) if (y1-y2)*(x3-x4) == (y3-y4)*(x1-x2): print "YES" else: print "NO"
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s625420836
p00021
Runtime Error
import sys def parallels(x1, y1, x2, y2, x3, y3, x4, y4): a1 = (y2-y1)/(x2-x1) a2 = (y4-y3)/(x4-x3) return a1 == a2 n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split(' ')) if parallels(x1, y1, x2, y2, x3, y3, x4, y4): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s859577760
p00021
Runtime Error
import sys def parallels(x1, y1, x2, y2, x3, y3, x4, y4): a1 = (y2-y1)/(x2-x1) a2 = (y4-y3)/(x4-x3) return a1 == a2 n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split(' ')) if y1-y2 == 0 and x3-x4 == 0: print 'YES' elif y1-y2 != 0 and x3-x4 == 0: print 'NO' elif y1-y2 == 0 and x3-x4 != 0: print 'NO' else: if parallels(x1, y1, x2, y2, x3, y3, x4, y4): print 'YES' else: print 'NO'
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s332963444
p00021
Runtime Error
n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split()) print('YES' if abs(x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.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>Parallelism</H1> <p> There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "<span>YES</span>" and if not prints "<span>NO</span>". </p> <H2>Input</H2> <p> Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:<br/> <br/> $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$<br/> </p> <p> You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point. </p> <H2>Output</H2> <p> For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line. </p> <H2>Sample Input</H2> <pre> 2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0 </pre> <H2>Output for the Sample Input</H2> <pre> YES NO </pre>
s067860456
p00022
Wrong Answer
while True: cnt = -10000 n = int(raw_input()) if n == 0: break else: tmp = 0 for i in range(n): tmp += int(raw_input()) cnt = max(cnt,tmp) print cnt
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s487482726
p00022
Wrong Answer
while True: cnt = -100000 n = int(raw_input()) if n == 0: break else: tmp = 0 for i in range(n): tmp += int(raw_input()) cnt = max(cnt,tmp) print cnt
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s472116154
p00022
Wrong Answer
while 1: n=int(input()) if n==0:break nlist=[] nans=-100001 for i in range(n): nlist.append(int(input())) nkeep=0 for i in nlist: if i>0 and nkeep>=0: nkeep+=i elif nkeep<0: nkeep=i if nans<nkeep:nans=nkeep if max(nlist)<0:nans=max(nlist) print(nans)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s667898259
p00022
Wrong Answer
while True: N=int(input()) if N==0: break num=0 res=-11111111 for i in range(N): a=int(input()) num=max(num+a,a) res=max(num,res) print(num)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s417170076
p00022
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- n = [] a = [] i = 0 while True: n.append(int(input())) if n[i] == 0: break for j in range(0,n[i]): a.append(int(input())) i += 1 count = 0 for i in range(0,len(n)): sumMax = 0 for j in range(count,count + n[i]): tmp = a[j] for k in range(j,count + n[i]): if j==k: continue tmp += a[k] sumMax = max(sumMax,tmp) count += n[i] print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s472955444
p00022
Wrong Answer
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys class Hoge(object): def __init__(self): pass def func(self): ''' insert your code ''' while True: n = input() if n == 0: break num = [input() for i in range(n)] s = [[0 for i in range(n+1)] for j in range(n+1)] for i in range(n): s[i][0] = num[i] for j in range(1, n-i): s[i][j] += s[i][j-1] + num[i+j] # for i in range(10): # for j in range(10): # print s[i][j] # print m = -float('inf') for i in range(n): for j in range(n): m = max(m, s[i][j]) print m return None if __name__ == '__main__': h = Hoge() h.func()
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s455449527
p00022
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- n = [] a = [] i = 0 while True: n.append(int(input())) if n[i] == 0: break for j in range(0,n[i]): a.append(int(input())) i += 1 count = 0 for i in range(0,len(n)): sumMax = 0 for j in range(count,count + n[i]): tmp = 0 for k in range(j,count + n[i]): tmp += a[k] sumMax = max(sumMax,tmp) count += n[i] print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s175023335
p00022
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- n = [] a = [] i = 0 while True: n.append(int(input())) if n[i] == 0: n.pop() break for j in range(0,n[i]): a.append(int(input())) i += 1 count = 0 for i in range(0,len(n)): sumMax = 0 for j in range(count,count + n[i]): tmp = 0 for k in range(j,count + n[i]): tmp += a[k] sumMax = max(sumMax,tmp) count += n[i] print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s212120708
p00022
Wrong Answer
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys class Hoge(object): def __init__(self): pass def func(self): ''' insert your code ''' while True: n = input() if n == 0: break num = [input() for i in range(n)] s = [[-1000000 for j in range(n+1)] for i in range(n+1)] for i in range(n): s[i][0] = num[i] for j in range(1, n-i): s[i][j] += s[i][j-1] + num[i+j] # for i in range(10): # for j in range(10): # print s[i][j] # print m = -float('inf') for i in range(n): for j in range(n): m = max(m, s[i][j]) print m return None if __name__ == '__main__': h = Hoge() h.func()
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s691863383
p00022
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- i = 0 while True: n = int(input()) if n == 0: break a = [] for i in range(0,n): a.append(int(input())) sumMax = 0 for i in range(0,n): tmp = 0 for j in range(i,n): tmp += a[j] sumMax = max(sumMax,tmp) print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s173911701
p00022
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: n = int(input()) if n == 0: break a = [] for i in range(0,n): a.append(int(input())) sumMax = -10001 for i in range(0,n): tmp = 0 for j in range(i,n): tmp += a[j] sumMax = max(sumMax,tmp) print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s765954899
p00022
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: n = int(input()) if n == 0: break a = [] for i in range(0,n): a.append(int(input())) sumMax = -10001 for i in range(0,n): tmp = 0 for j in range(i,n): tmp += a[j] if tmp > sumMax: sumMax = tmp print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s953258966
p00022
Wrong Answer
while True: n=int(input()) if n == 0: break s=0 for _ in range(n): i = int(input()) if i > 0: s+=i print(s)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s743151559
p00022
Wrong Answer
while True: n=int(input()) if n == 0: break ans=0 l=[] for _ in range(n): l.append(int(input())) for i in range(n): s=0 for j in range(i,n): s+=l[j] if ans < s: ans = s print(ans)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s026496631
p00022
Wrong Answer
while True: n=int(input()) if n == 0: break ans=0 l=[] for _ in range(n): l.append(int(input())) for i in range(n): s=-1e100 for j in range(i,n): s+=l[j] if ans < s: ans = s print(ans)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s449358282
p00022
Wrong Answer
while 1: n=input() if n==0:break m=0 r=0 for x in [input() for i in range(n)]: m=max(m,0)+x r=max(r,m) print r
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s387710640
p00022
Wrong Answer
while 1: n=input() if n==0:break m=0 r=-1e5 for x in[input()for i in range(n)]: m=max(m,0)+x r=max(r,m) print r
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s822865662
p00022
Wrong Answer
while True: n = int(raw_input()) if n == 0: break data_set = [int(raw_input()) for i in xrange(n)] start_index = -1 minus_index = -1 stop_index = -1 answer = 0 for index, num in enumerate(data_set): if num > 0: if start_index == -1: start_index = index elif minus_index != -1: stop_index = index elif num <= 0: if start_index != -1 and minus_index == -1: minus_index = index if stop_index != -1: total = sum(data_set[start_index:minus_index]) if not answer or total > answer: answer = total minus_index = -1 stop_index = -1 else: if not answer: answer = sum(data_set[start_index:minus_index]) total = sum(data_set[start_index:]) if total > answer: answer = total print answer
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s687294576
p00022
Wrong Answer
while True: n = int(raw_input()) if n == 0: break data_set = [int(raw_input()) for i in xrange(n)] start_index = -1 minus_index = -1 stop_index = -1 answer = 0 max_minus = '' for index, num in enumerate(data_set): if num > 0: if start_index == -1: start_index = index elif minus_index != -1: stop_index = index elif num <= 0: if max_minus == '' or num > max_minus: max_minus = num if start_index != -1 and minus_index == -1: minus_index = index if stop_index != -1: total = sum(data_set[start_index:minus_index]) if not answer or total > answer: answer = total minus_index = -1 stop_index = -1 else: if not answer: answer = sum(data_set[start_index:minus_index]) total = sum(data_set[start_index:]) if total > answer: answer = total if start_index == -1: print max_minus else: print answer
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s458960359
p00022
Wrong Answer
import sys n = 1 while 1: n = int(input()) if n == 0: break a = [int(input()) for _ in range(n)] print(sum(a))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s787517435
p00022
Wrong Answer
import sys while 1: n = int(input()) if n == 0: break a = [int(input()) for _ in range(n)] sumMax = 0 s = [] for i in range(len(a)+1): s.append(sum(a[0:i])) for i in range(len(a)+1): for j in range(1, len(a)+1): if (s[j] - s[i-1]) > sumMax: sumMax = s[j] - s[i-1] print(sumMax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s884257982
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break res = 0 s = 0 for i in range(n): a = int(input()) s = max(s + a, 0) res = max(s, res) print(res)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s864594574
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break res = -1111111111 s = 0 for i in range(n): a = int(input()) s = max(s + a, 0) res = max(s, res) print(res)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s829524592
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break res = -1111111111 s = 0 for i in range(n): a = int(input()) s = max(s + a, a, 0) res = max(s, res) print(res)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s166646479
p00022
Wrong Answer
while 1: ans=0 n=int(raw_input()) if (n==0): exit() for i in range(n): ans=max(ans,ans+int(raw_input())) print ans
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s272696545
p00022
Wrong Answer
from math import * PI = 3.1415926535898 while True: try: ans = -111111 * 5555 n = input() if n == 0: break res = [] arr = [] su = 0 for i in range(n): arr.append(input()) ans = max(ans, arr[i]) res.append(arr[0]) for i in range(1, n): res.append(res[i-1] + arr[i]) res = [0] + res for i in range(n+1): for j in range(i, n+1): ans = max(ans, res[j] - res[i]) print ans except EOFError: break
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s773804001
p00022
Wrong Answer
while True: num = int(input()) if not num: break result = 0 for _ in range(num): new = int(input()) result = max(new, result, result+new) print(result)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s902634521
p00022
Wrong Answer
while True: num = int(input()) if not num: break result, tmp = 0, 0 for _ in range(num): new = int(input()) tmp = max(new, new+tmp) result = max(tmp, result) print(new, tmp, result) if tmp < 0: result = tmp print(result)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s781113158
p00022
Wrong Answer
while True: num = int(input()) if not num: break result, tmp = 0, 0 for _ in range(num): new = int(input()) tmp = max(new, new+tmp) result = max(tmp, result) print(result)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s303462830
p00022
Wrong Answer
while True: num = int(input()) if not num: break result, tmp = -1e2, 0 for _ in range(num): new = int(input()) tmp = max(new, new+tmp) result = max(tmp, result) print(result)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s172069369
p00022
Wrong Answer
import itertools while True: n = int(input()) if n == 0: break else: a = [int(input()) for i in range(n)] a = list(itertools.accumulate(a)) a.insert(0, 0) ans = a[1] for j in range(n + 1): for k in range(n + 1): ans = max(ans, a[k] - a[j]) print(ans)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s401087531
p00022
Wrong Answer
import itertools while True: n = int(input()) if n == 0: break else: a = [int(input()) for i in range(n)] a = list(itertools.accumulate(a)) a.insert(0, 0) ans = -1000000 for j in range(n + 1): for k in range(n + 1): ans = max(ans, a[k] - a[j]) print(ans)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s432655204
p00022
Wrong Answer
while(1): n = int(input()) if n == 0: break else: ary = [] mx = 0 for i in range(n): ary.append(int(input())) for i in range(1, n + 1): sm = sum(ary[0:i]) if mx < sm: mx = sm for j in range(1, n - i + 1): sm = sm - ary[j - 1] + ary[j + i - 1] if mx < sm: mx = sm print(mx)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s623212027
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break ary = [] dp = [0] for i in range(n): ary.append(int(input())) for i in range(n): dp.append(max(dp[i] + ary[i], ary[i])) print(max(dp))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s909169081
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break dp = [0] for i in range(n): a = int(input()) dp.append(max(dp[i] + a, a)) print(max(dp))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s459647546
p00022
Wrong Answer
#! -*-coding:utf-8-*- def signCheck(argn): if argn>0: return 1 elif argn==0: return 1 else: return -1 def maxSumSequence(nums): pluslist=[] minuslist=[] prenum = 0 presign=signCheck(nums[0]) begin=presign nsum=0 for num in nums: nowsign=signCheck(num) if nowsign>0: if presign==nowsign: nsum+=num else: minuslist.append(nsum) nsum=num #?¬????????????????????????????????????? else: if presign==nowsign: nsum+=num else: pluslist.append(nsum) nsum=num presign=nowsign if nowsign>0: pluslist.append(nsum) else: minuslist.append(nsum) if begin<0: del minuslist[0] if nowsign<0: minuslist[-1]=0 sumlist=[] sumlist.append(pluslist[0]) del pluslist[0] for pnum,mnum in zip(pluslist,minuslist): sumlist.append(pnum+mnum) return sumlist def main(): while True: n=input() if n==0: break nums = [] minus_only=True for i in xrange(n): innum=input() nums.append(innum) if minus_only and innum>0: minus_only = False if minus_only: print max(nums) else: while len(nums)>1: nums = maxSumSequence(nums) print nums[0] if __name__ == '__main__': main()
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s409313571
p00022
Wrong Answer
#! -*-coding:utf-8-*- def signCheck(argn): if argn>0: return 1 elif argn==0: return 1 else: return -1 def maxSumSequence(nums,plusmax=0): pluslist=[] minuslist=[] prenum = 0 presign=signCheck(nums[0]) begin=presign nsum=0 for num in nums: nowsign=signCheck(num) if nowsign>0: if presign==nowsign: nsum+=num else: minuslist.append(nsum) nsum=num #?¬????????????????????????????????????? else: if presign==nowsign: nsum+=num else: pluslist.append(nsum) nsum=num presign=nowsign if nowsign>0: pluslist.append(nsum) else: minuslist.append(nsum) if plusmax<max(pluslist): plusmax=max(pluslist) #?????????????????????????????????????????? if begin<0: del minuslist[0] #????????????????????????????????????????????? if nowsign<0: minuslist[-1]=0 sumlist=[] sumlist.append(pluslist[0]) del pluslist[0] for pnum,mnum in zip(pluslist,minuslist): sumlist.append(pnum+mnum) return sumlist,plusmax def main(): while True: n=input() if n==0: break nums = [] minus_only=True for i in xrange(n): innum=input() nums.append(innum) if minus_only and innum>0: minus_only = False if minus_only: print max(nums) else: plusmax=0 while len(nums)>1: nums,plusmax = maxSumSequence(nums,plusmax) if nums[0]<plusmax: print plusmax else: print nums[0] if __name__ == '__main__': main()
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s123431536
p00022
Wrong Answer
while True: n=int(input()) if n==0: break A=[] for i in range(n): x=int(input()) A.append(x) B=[int()]*n B[0]=A[0] for i in range(n): if A[i]>=A[i]+B[i-1]: B[i]=A[i] else: B[i]=A[i]+B[i-1] print(max(B))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s796553873
p00022
Wrong Answer
while True: n = int(input()) if not n: break A = [] for i in range(n): a = int(input()) A.append(a) smax = A[0] ssum = A[0] for a in A[1:]: if a + ssum > smax: smax = a + ssum ssum = max(ssum+a, 0) print(smax)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s535792978
p00022
Wrong Answer
while 1: n = int(input()) if n == 0: break t = [int(input()) for i in range(n)] m = sum(t) while len(t) > 1: if t[0] < t[-1]: a = t.pop(0) else: a = t.pop(-1) if a < 0: m = max(sum(t), m) print(m)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s525821476
p00022
Wrong Answer
while 1: n=input() if n==0:break a=[int(raw_input()) for _ in xrange(n)] wa=[0]*(n+1) max_a=-1000000 for i in xrange(n): wa[i+1]=a[i]+wa[i] for i in xrange(n): for j in xrange(i,n+1): if max_a<wa[j]-wa[i]: max_a=wa[j]-wa[i] print(max_a)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s924034630
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break a = [int(input()) for _ in range(n)] a[:0] = [0] for i in range(1, len(a)): a[i] += a[i - 1] print(max(a) - min(a))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s394077841
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break a = [int(input()) for _ in range(n)] b = [] while a != []: for i in range(len(a) - 1): if a[i] * a[i + 1] < 0: b.append(sum(a[:i + 1])) a[:i + 1] = [] break else: b.append(sum(a)) a = [] for i in range(1, len(b)): if b[i - 1] > 0: b[i] += b[i - 1] print(max(b))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s332082856
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break max_ = -999999 a = [int(input()) for x in range(n)] for i in range(n - 1): m = a[i] for j in range(i + 1, n): m += a[j] if m > max_: max_ = m print(max_)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s938833819
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break max_ = -999999 a = [int(input()) for x in range(n)] for i in range(n): m = a[i] for j in range(i + 1, n): m += a[j] if m > max_: max_ = m print(max_)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s571870842
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break max_ = -10000000 a = [int(input()) for x in range(n)] for i in range(n - 1): m = a[i] for j in range(i + 1, n): m += a[j] if m > max_: max_ = m print(max_)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s258898093
p00022
Wrong Answer
while True: n = int(input()) if n == 0: break max_ = -1000000 a = [int(input()) for x in range(n)] for i in range(n - 1): m = a[i] for j in range(i + 1, n): m += a[j] if m > max_: max_ = m print(max_)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s973330687
p00022
Wrong Answer
while 1: n = input() if n == 0: break a, b, c = 0, 0, input() sums = [c] for i in xrange(n - 1): a, b, c = b, c, input() sums.append(a + b + c) print max(sums)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s943805318
p00022
Wrong Answer
while 1: r = 0 n = input() if n == 0: break nums = [] for i in xrange(n): nums.append(input()) for i in xrange(n): if nums[i] < 0: continue sums = [0] for j in nums[i:]: sums.append(sums[-1] + j) r = max(sums) if r < max(sums) else r print r
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s789307183
p00022
Wrong Answer
while 1: n = input() if n == 0: break sums = [0] for i in xrange(n): num = input() sums.append(max(sums[-1] + num, num)) print max(sums)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s042076594
p00022
Wrong Answer
while True: N = int(input()) if N == 0: break A = [int(input()) for i in range(N)] ans = 0 cur = 0 for i in A: cur = max(cur + i,i) ans = max(ans,cur) print(ans)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>
s014235565
p00022
Wrong Answer
while True: n = int(input()) if n==0: break line = [int(input()) for i in range(n)] sum_li = [sum(line[:i]) for i in range(1,n+1)] key = sum_li.index(max(sum_li))+1 result = [sum(line[i:key]) for i in range(key)] print(max(result))
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each data set consists of: <pre> <var>n</var> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> . . <var>a<sub>n</sub></var> </pre> <p> You can assume that 1 &le; <var>n</var> &le; 5000 and -100000 &le; <var>a<sub>i</sub></var> &le; 100000. </p> <p> The input end with a line consisting of a single 0. </p> <H2>Output</H2> <p> For each dataset, print the maximum sum in a line. </p> <H2>Sample Input</H2> <pre> 7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0 </pre> <H2>Output for the Sample Input</H2> <pre> 19 14 1001 </pre>