Problem:


長方形の重なり

底辺が x 軸に対して平行な 2 つの長方形があります。長方形 A の左下の座標 (xa1, ya1) と右上の座標 (xa2, ya2)、長方形 B の左下の座標 (xb1, yb1) と右上の座標 (xb2, yb2) を読み込んで、長方形 A と長方形 B が一部でも重なっていれば YES を、まったく重なっていなければ NO を出力するプログラムを作成してください。ただし、長方形 A と長方形 B は同じものではないとします。また、接しているものも重なっているとみなします。

Input

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

xa1 ya1 xa2 ya2 xb1 yb1 xb2 yb2

入力される値はそれぞれ -2,000 以上 2,000 以下であり、各値は小数点以下最大 5 桁までの数字を含む実数で与えられます。

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

Output

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

Sample Input

0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0
0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0
0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0

Output for the Sample Input

YES
YES
NO



Sample input:
0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0
0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0
0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0


Sample output:
YES
YES
NO

Submission status: Accepted

Solution code:
while 1:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=map(float, raw_input().split())
        print "NO" if xa2<xb1 or xb2<xa1 or ya2<yb1 or yb2<ya1 else "YES"
    except EOFError:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float, raw_input().split())
        print "NO" if (xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < yb1) else "YES"
    except:
        break

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
    a,b,c,d,e,f,g,h=map(float,s.split())
    print ["YES","NO"][c<e or g<a or d<f or h<b]

Submission status: Accepted

Solution code:
try:
    while True:
        a = map(float, raw_input().split())
        if (a[0] < a[4] > a[2] or a[0] > a[6] < a[2] or
                a[1] < a[5] > a[3] or a[1] > a[7] < a[3]):
            print 'NO'
        else:
            print 'YES'
except EOFError:
    pass

Submission status: Accepted

Solution code:
while True:
    try:
        lst = list(map(float, input().split()))
        xa1, ya1 = lst[0], lst[1]
        xa2, ya2 = lst[2], lst[3]
        xb1, yb1 = lst[4], lst[5]
        xb2, yb2 = lst[6], lst[7]
        
        if xb2 < xa1 or yb2 < ya1 or xa2 < xb1 or ya2 < yb1:
            print("NO")

        else:
            print("YES")

    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        if max(xa1, xb1) <= min(xa2, xb2) and max(ya1, yb1) <= min(ya2, yb2):
            print('YES')
        else:
            print('NO')

    except:
        break

Submission status: Accepted

Solution code:
while 1:
    try:ax, ay, bx, by, cx, cy, dx, dy = map(float, input().split())
    except:break
    if (ax<=dx and cx<=bx) and (ay<=dy and cy<=by):
        print('YES')
    else:print('NO')

Submission status: Accepted

Solution code:
import itertools as ite
import math

INF = 10 ** 18
try:
    while True:
        x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
        if (x1 <= x3 <= x2 or x1 <= x4 <= x2) and (y1 <= y3 <= y2 or y1 <= y4 <= y2):
            print "YES"
        elif (x3 <= x1 <= x4 or x3 <= x2 <= x4) and (y3 <= y1 <= y4 or y3 <= y2 <= y4):
            print "YES"
        elif (x1 <= x3 <= x2 and x1 <= x4 <= x2) and (y3 <= y1 <= y4 and y3 <= y2 <= y4):
            print "YES"
        elif (x3 <= x1 <= x4 and x3 <= x2 <= x4) and (y1 <= y3 <= y2 and y1 <= y4 <= y2):
            print "YES"
        else:
            print "NO"
except:
    pass

Submission status: Accepted

Solution code:
while(1):
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = [float(i) for i in input().split()]
        if xa2 < xb1 or xb2 < xa1 or ya2 < yb1 or yb2 < ya1:
            print("NO")
        else:
            print("YES")
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
import sys
f = sys.stdin


def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)

for line in f:
    a1,a2,b1,b2 = [x + y * 1j for x, y in take2(map(float, line.split()))]
    
    if (min(a1.real, a2.real) <= b1.real <= max(a1.real, a2.real) or (min(a1.real, a2.real) <= b2.real <= max(a1.real, a2.real))) and 
    (min(a1.imag, a2.imag) <= b1.imag <= max(a1.imag, a2.imag) or (min(a1.imag, a2.imag) <= b2.imag <= max(a1.imag, a2.imag))):
        print('YES')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
def solve(xa,ya1,xa1,ya2,xb1,yb1,xb2,yb2):
	if xb2<xa1 or xb1>xa2 or yb2<ya1 or yb1>yb2:
		print("NO")
	else:
		print("YES")


while True:
	try:
		xa,ya1,xa1,ya2,xb1,yb1,xb2,yb2=map(float,input().split())
		solve(xa,ya1,xa1,ya2,xb1,yb1,xb2,yb2)
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split(' '))
    if (xa1 <= xb1 <= xa2 or xb1 <= xa1 <= xb2) and (yb1 <= ya2 <= yb2 or ya1 <= yb2 <= ya2):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split(' '))
    if (xa1 <= xb1 <= xa2 or xb1 <= xa1 <= xb2) and (yb1 <= ya2 <= yb2 or ya1 <= yb2 <= ya2):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:
import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = tuple(map(float, line.split(' ')))
    if (xa1 <= xb1 <= xa2 or xb1 <= xa1 <= xb2) and (yb1 <= ya2 <= yb2 or ya1 <= yb2 <= ya2):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split(' '))
    if (xa1 <= xb1 and xb1 <= xa2 or xb1 <= xa1 and xa1 <= xb2) and (yb1 <= ya2 and ya2 <= yb2 or ya1 <= yb2 and yb2 <= ya2):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split(' '))
    if ((xa1 <= xb1 and xb1 <= xa2) or (xb1 <= xa1 and xa1 <= xb2)) and ((yb1 <= ya2 and ya2 <= yb2) or (ya1 <= yb2 and yb2 <= ya2)):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split(' '))
    if ((xa1<=xb1 and xb1<=xa2) or (xb1<=xa1 and xa1<=xb2)) and ((yb1<=ya2 and ya2<=yb2) or (ya1<=yb2 and yb2<=ya2)):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split(' '))
    if ((xb1<=xa1 and xa1<=xb2) or (xa1<=xb1 and xb1<=xa2)) and ((yb1<=ya2 and ya2<=yb2) or (ya1<=yb2 and yb2<=ya2)):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.rstrip('\n').split(' '))
    if ((xb1<=xa1 and xa1<=xb2) or (xa1<=xb1 and xb1<=xa2)) and ((yb1<=ya2 and ya2<=yb2) or (ya1<=yb2 and yb2<=ya2)):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:

import sys


for line in sys.stdin.readline():
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.rstrip('\n').split(' '))
    if ((xb1<=xa1 and xa1<=xb2) or (xa1<=xb1 and xb1<=xa2)) and ((yb1<=ya2 and ya2<=yb2) or (ya1<=yb2 and yb2<=ya2)):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:
import sys


for line in sys.stdin.readline():
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.rstrip('\n').split(' '))
    if ((xb1<=xa1 and xa1<=xb2) or (xa1<=xb1 and xb1<=xa2)) and ((yb1<=ya2 and ya2<=yb2) or (ya1<=yb2 and yb2<=ya2)):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:
def Check(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2)
    # the case A's upper left point in B
    if xb1 <= xa1 <= xb2 and yb1 <= ya2 <= yb2:
        return True
    # the case A's upper rihgt point in B
    if xb1 <= xa2 <= xb2 and yb1 <= ya2 <= yb2:
        return True
    # the case A's lowerr left point in B
    if xb1 <= xa1 <= xb2 and yb1 <= ya1 <= yb2:
        return True
    # the case A's lowerr right point in B
    if xb1 <= xa2 <= xb2 and yb1 <= ya1 <= yb2:
        return True

while True:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float, raw_input().split())
        print "YES" if Check(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2) else "NO"
    except:
        break