Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

直交判定

平面上の異なる 4 点、$A (x_A, y_A)$, $B (x_B, y_B)$, $C (x_C, y_C)$, $D (x_D, y_D)$ の座標を読み込んで、直線 $AB$ と $CD$ が直交する場合には YES、直交しない場合には NO と出力するプログラムを作成してください。ここで、「直線」とは線分のことではありません。以下の図を参考にして下さい。

Input

複数のデータセットが与えられます。各データセットの形式は以下のとおりです。

$x_A$ $y_A$ $x_B$ $y_B$ $x_C$ $y_C$ $x_D$ $y_D$

$x_A$, $y_A$, $x_B$, $y_B$, $x_C$, $y_C$, $x_D$, $y_D$ はそれぞれ -100 以上 100 以下であり、各値は小数点以下最大 5 桁までの数字を含む実数で与えられます。

データセットの数は 100 を超えません。

Output

各データセットに対して、YES または NO を１行に出力して下さい。

Sample Input

1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0
0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0
10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1
2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3

Output for the Sample Input

YES
NO
NO
YES



Sample input:
1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0
0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0
10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1
2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3


Sample output:
YES
NO
NO
YES

Submission status: Accepted

Solution code:
while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    except:
        break
    if abs((ya - yb) * (yc - yd) + (xa - xb) * (xc - xd)) < 1.e-10:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
    xa,ya,xb,yb,xc,yc,xd,yd = map(float,s.split())
    if abs( (xb-xa)*(xd-xc)+(yb-ya)*(yd-yc) )< 1e-10: print "YES"
    else: print "NO"

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

def take2(iterable):
    while True:
        yield next(iterable), next(iterable)
#内積
def dot(v1, v2):
    return v1.real * v2.real + v1.imag * v2.imag

for line in f:
    a,b,c,d = [x + y * 1j for x, y in take2(map(float, line.split()))]
    
    #内積の絶対値が十分に小さい時、直行と判断する
    print('YES' if abs(dot(a - b, c - d)) < 1.e-10 else 'NO')

Submission status: Accepted

Solution code:
while True:
	try:
		xA,yA,xB,yB,xC,yC,xD,yD = map(float,raw_input().split())
	except EOFError:
		break
	
	if abs((xA - xB) * (xC - xD) + (yA - yB) * (yC - yD)) < 1e-10:
		print "YES"
	else:
		print "NO"

Submission status: Accepted

Solution code:
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
while 1:
    try:
        xa,ya,xb,yb,xc,yc,xd,yd=map(float,raw_input().split())
        print 'YES' if choco(xa,ya,xb,yb,xc,yc,xd,yd) else 'NO'
    except:
        break

Submission status: Accepted

Solution code:
def dot(x, y):
    return (x.conjugate() * y).real
    
def is_orthogonal(x, y):
    if abs(dot(x, y)) < 1e-10:
        return True
    return False
        
import sys

for line in sys.stdin:
    li = list(map(float, line.split()))
    p = []
    for i in range(0, len(li), 2):
        p.append(complex(li[i], li[i+1]))
    d1 = p[1] - p[0]
    d2 = p[3] - p[2]
    
    if is_orthogonal(d1, d2):
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

class Point_class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

import sys

for line in sys.stdin:
    A = map(float, line.split())
    p = []
    for i in range(4):
        p.append(Point_class(A[2*i], A[2*i+1]))
    if abs((p[3].y-p[2].y)*(p[1].y-p[0].y) + (p[3].x-p[2].x)*(p[1].x-p[0].x)) < 1e-10:
        print "YES"
    else:
        print "NO"

Submission status: Accepted

Solution code:
while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    except:
        break
    ab = (xb - xa, yb - ya)
    cd = (xd - xc, yd - yc)
    if abs(ab[0] * cd[0] + ab[1] * cd[1]) < 1e-11:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
  l = list(map(float,line.split()))
  ax,ay,bx,by,cx,cy,dx,dy = [int(i*(10**5)) for i in l] 
  dx1 = bx - ax
  dy1 = by - ay
  dx2 = dx - cx
  dy2 = dy - cy
  x = dx1 * dx2
  y = dy1 * dy2
  if x + y == 0:
    print("YES")
  else:
    print("NO")

Submission status: Accepted

Solution code:
while 1:
    try:ax, ay, bx, by, cx, cy, dx, dy = map(float, input().split())
    except:break
    print(['NO','YES'][abs((ay - by)*(cy-dy)+(ax-bx)*(cx-dx))<1e-10])

Submission status: Accepted

Solution code:
def dot(u,v):
    return(u[0]*v[0] + u[1]*v[1])

def solve(v):
    eps = 1e-10
    xa,ya,xb,yb,xc,yc,xd,yd = v
    if abs(dot( (xb-xa, yb-ya), (xd-xc, yd-yc)) ) < eps:
        return(True)
    else:
        return(False)

while True:
    try:
        v = map(float, input().strip().split())
        if solve(v):
            print("YES")
        else:
            print("NO")
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    except EOFError:
        break
    if x1 == x2:
        if y3 == y4:
            print('YES')
        else:
            print('NO')
        continue
    elif x3 == x4:
        if y1 == y2:
            print('YES')
        else:
            print('NO')
        continue
    p = (y2 - y1) / (x2 - x1)
    q = (y4 - y3) / (x4 - x3)
    EPS = 1e-9
    if -1.0 - EPS <= p * q <= -1.0 + EPS:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    ax, ay, bx, by, cx, cy, dx, dy = map(float, s.split())

    AB = (bx - ax, by - ay)
    CD = (dx - cx, dy - cy)

    cross = AB[0] * CD[0] + AB[1] * CD[1]

    epsilon = 1e-10
    if abs(cross) < epsilon:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
# Aizu Problem 0058: Orthogonal
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, x4, y4 = [float(_) for _ in line.split()]
    scalar_product = (x2 - x1) * (x4 - x3) + (y2 - y1) * (y4 - y3)
    print("YES" if abs(scalar_product) < 1e-10 else "NO")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0021&lang=jp
WA
"""
import sys
from sys import stdin
input = stdin.readline



class Point(object):
    epsilon = 1e-10

    def __init__(self, x=0.0, y=0.0):
        if isinstance(x, tuple):
            self.x = x[0]
            self.y = x[1]
        else:
            self.x = x
            self.y = y

    # ????????????
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Point(other * self.x, other * self.y)

    def __truediv__(self, other):
        return Point(self.x / other, self.y / other)

    def __lt__(self, other):
        if self.x == other.x:
            return self.y < other.y
        else:
            return self.x < other.x

    def __eq__(self, other):
        from math import fabs
        if fabs(self.x - other.x) < Point.epsilon and fabs(self.y - other.y) < Point.epsilon:
            return True
        else:
            return False

    def norm(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return sqrt(self.norm())

    def ccw(self, p0, p1):
        # ??????2???(p0, p1)?????????????????????????????????????????¢????????????
        a = Vector(p1 - p0)
        b = Vector(self - p0)
        if Vector.cross(a, b) > Point.epsilon:
            return 1 # 'COUNTER_CLOCKWISE'
        elif Vector.cross(a, b) < -Point.epsilon:
            return -1 # 'CLOCKWISE'
        elif Vector.dot(a, b) < -Point.epsilon:
            return 2 # 'ONLINE_BACK'
        elif a.norm() < b.norm():
            return -2 # 'ONLINE_FRONT'
        else:
            return 0 # 'ON_SEGMENT'

    def project(self, s):
        # ??????(Point)????????????s??????????????????????????????????????§?¨?(?°???±)????±???????
        base = Vector(s.p2 - s.p1)
        a = Vector(self - s.p1)
        r = Vector.dot(a, base)
        r /= base.norm()
        return s.p1 + base * r

    def reflect(self, s):
        # ??????s???????§°?????¨?????????????????¨???????§°??????????????§?¨?(????°?)????±???????
        proj = self.project(s)
        return self + (proj - self)*2

    def distance(self, s):
        # ????????¨??????s????????¢????¨??????????
        if Vector.dot(s.p2-s.p1, self-s.p1) < 0.0:
            return abs(self - s.p1)
        if Vector.dot(s.p1-s.p2, self-s.p2) < 0.0:
            return abs(self - s.p2)
        return abs(Vector.cross(s.p2-s.p1, self-s.p1) / abs(s.p2-s.p1))


class Vector(Point):
    def __init__(self, x=0.0, y=0.0):
        if isinstance(x, tuple):
            self.x = x[0]
            self.y = x[1]
        elif isinstance(x, Point):
            self.x = x.x
            self.y = x.y
        else:
            self.x = x
            self.y = y

    # ????????????
    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Vector(other * self.x, other * self.y)

    def __truediv__(self, other):
        return Vector(self.x / other, self.y / other)


    @classmethod
    def dot(cls, a, b):
        return a.x * b.x + a.y * b.y

    @classmethod
    def cross(cls, a, b):
        return a.x * b.y - a.y * b.x

    @classmethod
    def is_orthogonal(cls, a, b):
        return abs(Vector.dot(a, b)) < Vector.epsilon

    @classmethod
    def is_parallel(cls, a, b):
        return abs(Vector.cross(a, b)) < Vector.epsilon


class Segment(object):
    def __init__(self, p1=Point(), p2=Point()):
        if isinstance(p1, Point):
            self.p1 = p1
            self.p2 = p2
        elif isinstance(p1, tuple):
            self.p1 = Point(p1[0], p1[1])
            self.p2 = Point(p2[0], p2[1])

    def intersect(self, s):
        # ????????¨??????????????????????????????????????????????????????
        ans1 = s.p1.ccw(self.p1, self.p2) * s.p2.ccw(self.p1, self.p2)
        ans2 = self.p1.ccw(s.p1, s.p2) * self.p2.ccw(s.p1, s.p2)
        return ans1 <= 0 and ans2 <= 0

    def cross_point(self, s):
        # ????????¨??????????????????????????????????????§?¨?????±???????
        base = s.p2 - s.p1
        d1 = abs(Vector.cross(base, self.p1-s.p1))
        d2 = abs(Vector.cross(base, self.p2-s.p1))
        t = d1 / (d1 + d2)
        return self.p1 + (self.p2 - self.p1) * t

    def distance(self, s):
        # ????????¨?????????????????????????????¢????±???????
        if self.intersect(s):
            return 0.0
        d1 = s.p1.distance(self)
        d2 = s.p2.distance(self)
        d3 = self.p1.distance(s)
        d4 = self.p2.distance(s)
        return min(d1, d2, d3, d4)


    @classmethod
    def is_orthogonal(cls, s1, s2):
        a = Vector(s1.p2 - s1.p1)
        b = Vector(s2.p2 - s2.p1)
        return Vector.is_orthogonal(a, b)

    @classmethod
    def is_parallel(cls, s1, s2):
        a = Vector(s1.p2 - s1.p1)
        b = Vector(s2.p2 - s2.p1)
        return Vector.is_parallel(a, b)


class Line(Segment):
    pass


class Cirle(object):
    def __init__(self, x, y=Point(), r=1.0):
        if isinstance(x, Point):
            self.c = x
            self.r = y
        elif isinstance(x, tuple):
            self.c = Point(x[0], x[1])
            self.r = r

    def cross_points(self, s):
        if isinstance(s, Segment):
            pr = self.c.project(s)
            e = (s.p2 - s.p1) / abs(s.p2 - s.p1)
            base = sqrt(self.r * self.r - (pr - self.c).norm())
            return pr + e * base, pr - e * base
        elif isinstance(s, Cirle):
            c2 = s
            d = abs(self.c - c2.c)
            a = acos((self.r * self.r + d * d - c2.r * c2.r) / (2 * self.r * d))
            t = atan2(c2.c.y - self.c.y, c2.c.x - self.c.x)
            temp1 = Point(cos(t+a)*self.r, sin(t+a)*self.r)
            temp2 = Point(cos(t-a)*self.r, sin(t-a)*self.r)
            return self.c + temp1, self.c + temp2


def contains(polygon, p):
    n = len(polygon)
    x = False
    for i in range(n):
        a = polygon[i] - p
        b = polygon[(i+1)%n] - p
        if abs(Vector.cross(a, b)) < Point.epsilon and Vector.dot(a, b) < Point.epsilon:
            return 1
        if a.y > b.y:
            temp = a
            a = b
            b = temp
        if a.y < Point.epsilon and Point.epsilon < b.y and Vector.cross(a, b) > Point.epsilon:
            x = not x
    return 2 if x else 0


def main(args):
        for line in sys.stdin:
            x1, y1, x2, y2, x3, y3, x4, y4 = map(float, line.split())
            a = Point(x1, y1)
            b = Point(x2, y2)
            c = Point(x3, y3)
            d = Point(x4, y4)
            AB = Segment(a, b)
            CD = Segment(c, d)
            result = Segment.is_orthogonal(AB, CD)
            if result:
                print('YES')
            else:
                print('NO')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
while True:
    try:
        x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = map(float, input().split())
        ab_x, ab_y = x_b - x_a, y_b - y_a
        cd_x, cd_y = x_d - x_c, y_d - y_c
        dp = ab_x*cd_x + ab_y*cd_y
        if abs(dp) > 1e-10:
            print("NO")
        else:
            print("YES")
    except:
        break

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    Points = [float(i) for i in N[l].split()]
    P = []
    for i in range(8):
        P.append(int(Points[i]*10**5))
    AB = [P[2]-P[0],P[3]-P[1]]
    CD = [P[6]-P[4],P[7]-P[5]]
    if AB[0]*CD[0] + AB[1]*CD[1] == 0:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
import sys
for x in sys.stdin:
 a,b,c,d,e,f,g,h=map(float,x.split());z=1e-10
 print(['NO','YES'][-z<(a-c)*(e-g)+(b-d)*(f-h)<z])

Submission status: Accepted

Solution code:
import sys
for x in sys.stdin:
 a,b,c,d,e,f,g,h=map(float,x.split())
 print(['NO','YES'][abs((a-c)*(e-g)+(b-d)*(f-h))<1e-10])

Submission status: Accepted

Solution code:
while True:
    try:
        xa,ya,xb,yb,xc,yc,xd,yd=map(float,input().split())
    except EOFError:
        break
    if abs((ya-yb)*(yc-yd)+(xa-xb)*(xc-xd))<=1e-10:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
import sys
from decimal import Decimal as D
orth=lambda l:((D(l[2])-D(l[0]))*(D(l[6])-D(l[4]))+(D(l[3])-D(l[1]))*(D(l[7])-D(l[5])))
[print(l) for l in ["YES" if orth(j)==0 else "NO" for j in [l.split() for l in sys.stdin]]]

Submission status: Accepted

Solution code:
# AOJ 0058 Orthogonal
# Python3 2018.6.15 bal4u

EPS = 1e-11

def dot(a, b):
	return a.real*b.real + a.imag*b.imag

def cross(a, b):
	return a.real*b.imag - a.imag*b.real
	
def norm(a):
	return a.real**2 + a.imag**2
	
def project(line, p):
	base = line[1]-line[0]
	r = dot(p-line[0], base) / norm(base)
	return line[0] + base*r
	
def symmetric_Point(line, p):
	return p + 2*(project(line, p)-p)

def isParallelLL(line1, line2):
	t = cross(line1[1]-line1[0], line2[1]-line2[0])
	return -EPS <= t and t <= EPS

def isOrthogonalLL(line1, line2):
	t = dot(line1[1]-line1[0], line2[1]-line2[0])
	return -EPS <= t and t <= EPS
	

while True:
	try: p = list(map(float, input().split()))
	except: break
	
	p1 = complex(p[0], p[1])
	p2 = complex(p[2], p[3])
	p3 = complex(p[4], p[5])
	p4 = complex(p[6], p[7])
	print('YES' if isOrthogonalLL([p1,p2], [p3,p4]) else 'NO')

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
    line=map(float,line.strip().split())
    x=line[0::2]
    y=line[1::2]
    vx=x[0]-x[1],x[2]-x[3]
    vy=y[0]-y[1],y[2]-y[3]
    if vx[0]*vx[1]+vy[0]*vy[1]+0==0:
        print "YES"
    else:
        print "NO"

Submission status: Accepted

Solution code:
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float,raw_input().split(' '))
        vec1 = [xA-xB,yA-yB]
        vec2 = [xC-xD,yC-yD]
        if vec1[0]*vec2[0]+vec1[1]*vec2[1] == 0.0:
            print 'YES'
        else:
            print 'NO'
    except EOFError: break

Submission status: Accepted

Solution code:

import sys


class Line:
    def __init__(self, xa, ya, xb, yb):
        self.vx = xa - xb
        self.vy = ya - yb

    def orthogonal(self, other):
        if self.vx * other.vx + self.vy * other.vy == 0.0:
            return 'YES'
        else:
            return 'NO'


for line in sys.stdin:
    xa, ya, xb, yb, xc, yc, xd, yd = tuple(map(float, line.split(' ')))
    line_a = Line(xa, ya, xb, yb)
    line_b = Line(xc, yc, xd, yd)
    print line_a.orthogonal(line_b)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    ax, ay, bx, by, cx, cy, dx, dy = (float(s) for s in line.split())

    tx, ty = (ax - bx, ay - by)
    sx, sy = (cx - dx, cy - dy)

    if round(tx * sy - ty * sx, 5) == 0.0:
        print('NO')
    elif round(tx * sx + ty * sy, 5) == 0.0:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
    a,b,c,d,e,f,g,h=map(float,s.split())
    if abs((c-a)*(g-e)+(d-b)*(h-f))<1e-10:m="YES"
    else:m="NO"
    print m

Submission status: Accepted

Solution code:
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float, raw_input().split())
        if abs((yB-yA)*(yD-yC) + (xB-xA)*(xD-xC)) < 1.e-12:
                print "YES"
        else:
            print "NO"
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float, raw_input().split())
        if abs((yB-yA)*(yD-yC) + (xB-xA)*(xD-xC)) < 1.e-10:
                print "YES"
        else:
            print "NO"
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
        if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) <= 1e-11 :
            print('YES')
        else:
            print('NO')

    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    EPS = 1e-9
    for line in readlines():
        conv = lambda x: int(float(x) * 100000)
        x1, y1, x2, y2, x3, y3, x4, y4 = map(conv, line.split())
        x1 -= x2; y1 -= y2
        x3 -= x4; y3 -= y4
        if x1*x3 + y1*y3 == 0:
            write("YES\n")
        else:
            write("NO\n")
solve()

Submission status: Accepted

Solution code:
import sys

while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = (float(x) for x in input().split(" "))
        ans = "NO"
        if x1 == x2:
            if y3 == y4:
                ans = "YES"
        else:
            if x3 == x4:
                if y1 == y2:
                    ans = "YES"
            else:
                k1 = (y2 - y1) / (x2 - x1)
                k2 = (y4 - y3) / (x4 - x3)
                if(abs((k1 * k2) + 1) < 1e-10):
                    ans = "YES"
        print(ans)
    except:
        break

Submission status: Accepted

Solution code:
#内積が0になるかを判定
while True:
    try:
        Ax,Ay,Bx,By,Cx,Cy,Dx,Dy=map(float, input().split())
    except:
        break
    #複素数化する
    A=complex(Ax,Ay)
    B=complex(Bx,By)
    C=complex(Cx,Cy)
    D=complex(Dx,Dy)
    #判定
    if -1e-10<((A-B)/(C-D)).real<1e-10:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
while 1:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
        if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) < 0.00000000001:
            print('YES')
        else:
            print('NO')
    except:
        break

Submission status: Accepted

Solution code:
while True:
  try:
    xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
  except:
    break
  abx = xb - xa
  aby = yb - ya
  cdx = xd - xc
  cdy = yd - yc
  if abs(abx * cdx + aby * cdy) < 10**(-10):
    print("YES")
  else:
    print("NO")

Submission status: Accepted

Solution code:
def dot(x, y):
    return (x.conjugate() * y).real
     
def is_orthogonal(x, y):
    if abs(dot(x, y)) < 1e-10:
        return True
    return False
         
import sys
 
for line in sys.stdin:
    li = list(map(float, line.split()))
    p = []
    for i in range(0, len(li), 2):
        p.append(complex(li[i], li[i+1]))
    d1 = p[1] - p[0]
    d2 = p[3] - p[2]
     
    if is_orthogonal(d1, d2):
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
while 1:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4=map(float,input().split())
        if y2-y1==0:
            if x3==x4:print("YES")
            else:print("NO")
        elif y4-y3==0:
            if x1==x2:print("YES")
            else:print("NO")
        else:
            if abs((x2-x1)/(y2-y1)*(x4-x3)/(y4-y3)+1)<0.0000001:print("YES")
            else:print("NO")
    except:break

Submission status: Accepted

Solution code:
E = 10**-10
while(1):
    try:
        xa,ya,xb,yb,xc,yc,xd,yd = [float(i) for i in input().split()]
        x1 = xb-xa
        y1 = yb-ya
        x2 = xd-xc
        y2 = yd-yc
        inner = x1*x2+y1*y2
        if abs(inner) < E:
            print("YES")
        else:
            print("NO")
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
def slant(xa, ya, xb, yb):
    if ya - yb == 0:
        return 'y'
    elif xa - xb == 0:
        return 'x'
    else:
        return (ya - yb) / (xa - xb)

while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    except:
        break
    AB = slant(xa, ya, xb, yb)
    CD = slant(xc, yc, xd, yd)
    is_digit = ('x' and 'y') not in [AB, CD]

    if [AB, CD] == (['x', 'y'] or ['y', 'x']):
        print('YES')
        continue

    if is_digit:
        print('YES' if AB * CD == -1 else 'NO')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float, raw_input().split())
        if (10000*(yB-yA))*(100000*(yD-yC)) +(100000*(xB-xA)*(100000*(xD-xC)) < 1.e-12:
            print "YES"
        else:
            print "NO"
    except:
        break

Submission status: Runtime Error

Solution code:
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float, raw_input().split())
        if (yB-yA)*(yD-yC) + (xB-xA)*(xD-xC) == 0.0:
                print "YES"
            else:
                print "NO"
        else:
            print "NO"
    except:
        break