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: Wrong Answer

Solution code:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
    except:
        break
    A = (xa1 <= xb1 <= xa2) and (ya1 <= yb2 <= ya2)
    B = (xa1 <= xb2 <= xa2) and (ya1 <= yb2 <= ya2)
    C = (xa1 <= xb2 <= xa2) and (ya1 <= yb1 <= ya2)
    D = (xa1 <= xb1 <= xa2) and (ya1 <= yb1 <= ya2)
    if A or B or C or D:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(lambda x:'%.10f' % float(x), input().split())
    except:
        break
    A = (xa1 <= xb1 <= xa2) and (ya1 <= yb2 <= ya2)
    B = (xa1 <= xb2 <= xa2) and (ya1 <= yb2 <= ya2)
    C = (xa1 <= xb2 <= xa2) and (ya1 <= yb1 <= ya2)
    D = (xa1 <= xb1 <= xa2) and (ya1 <= yb1 <= ya2)
    if A or B or C or D:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import sys

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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import sys
f = sys.stdin



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

def a_in_b_complex(a1,a2,b1,b2):
    return a_in_b(a1.real,a2.real,b1.real,b2.real) and a_in_b(a1.imag,a2.imag,b1.imag,b2.imag)

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

Submission status: Wrong Answer

Solution code:
def other_point(x1,y1,x2,y2):
	x3,y3,x4,y4=x1,y2,x2,y1
	return x3,y3,x4,y4


def Boolean(p_target,p1,p2):
	if p1<p_target<p2:
		return True
	else:
		return False




def solve(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
	#????§???¢a????????????
	xa3,ya3,xa4,ya4=other_point(xa1,ya1,xa2,ya2)
	#????§???¢b????????????
	xb3,yb3,xb4,yb4=other_point(xa1,ya1,xa2,ya2)

	#xb1????????????xa1,xa2??????????????????????????§???yb1????????????ya1,ya2?????????????????????
	#??¨
	#xb2????????????xa1,xa2??????????????????????????§???yb???????????????ya1,ya2?????????????????????
	#??¨
	#xb3????????????xa1,xa2??????????????????????????§???yb3????????????ya1,ya2?????????????????????
	#??¨
	#xb4????????????xa1,xa2??????????????????????????§ yb3????????????ya1,ya2?????????????????????
	#
	#????§????a,b?????????????????????????????????
	p1=Boolean(xb1,xa1,xa2) and Boolean(yb1,ya1,ya2)
	p2=Boolean(xb2,xa1,xa2) and Boolean(yb2,ya1,ya2)
	p3=Boolean(xb3,xa1,xa2) and Boolean(yb3,ya1,ya2)
	p4=Boolean(xb4,xa1,xa2) and Boolean(yb4,ya1,ya2)
	
	p5=Boolean(xa1,xb1,xb2) and Boolean(ya1,yb1,yb2)
	p6=Boolean(xa2,xb1,xb2) and Boolean(ya2,yb1,yb2)
	p7=Boolean(xa3,xb1,xb2) and Boolean(ya3,yb1,yb2)
	p8=Boolean(xa4,xb1,xb2) and Boolean(ya4,yb1,yb2)

	if (p1 or p2 or p3 or p4) or (p5 or p6 or p7 or p8):
		print("YES")
	else:
 		print("NO")


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

Submission status: Wrong Answer

Solution code:
def other_point(x1,y1,x2,y2):
	x3,y3,x4,y4=x1,y2,x2,y1
	return x3,y3,x4,y4


def Boolean(p_target,p1,p2):
	if p1<p_target<p2:
		return True
	else:
		return False


def solve(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
	#????§???¢a????????????
	xa3,ya3,xa4,ya4=other_point(xa1,ya1,xa2,ya2)
	#????§???¢b????????????
	xb3,yb3,xb4,yb4=other_point(xb1,yb1,xb2,yb2)

	#xb1????????????xa1,xa2??????????????????????????§???yb1????????????ya1,ya2?????????????????????
	#??¨
	#xb2????????????xa1,xa2??????????????????????????§???yb???????????????ya1,ya2?????????????????????
	#??¨
	#xb3????????????xa1,xa2??????????????????????????§???yb3????????????ya1,ya2?????????????????????
	#??¨
	#xb4????????????xa1,xa2??????????????????????????§ yb3????????????ya1,ya2?????????????????????
	#
	#????§????a,b?????????????????????????????????
	p1=Boolean(xb1,xa1,xa2) and Boolean(yb1,ya1,ya2)
	#print("p1",p1)
	p2=Boolean(xb2,xa1,xa2) and Boolean(yb2,ya1,ya2)
	#print("p2",p2)
	p3=Boolean(xb3,xa1,xa2) and Boolean(yb3,ya1,ya2)
	#print("p3",p3)
	p4=Boolean(xb4,xa1,xa2) and Boolean(yb4,ya1,ya2)
	#print("p4",p4)
	p5=Boolean(xa1,xb1,xb2) and Boolean(ya1,yb1,yb2)
	#print("p5",p1)
	p6=Boolean(xa2,xb1,xb2) and Boolean(ya2,yb1,yb2)
	#print("p6",p6)
	p7=Boolean(xa3,xb1,xb2) and Boolean(ya3,yb1,yb2)
	#print("p7",p1)
	p8=Boolean(xa4,xb1,xb2) and Boolean(ya4,yb1,yb2)
	#print("p8",p8)

	if (p1 or p2 or p3 or p4) or (p5 or p6 or p7 or p8):
		print("YES")
	else:
 		print("NO")


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

Submission status: Wrong Answer

Solution code:
def other_point(x1,y1,x2,y2):
	x3,y3,x4,y4=x1,y2,x2,y1
	return x3,y3,x4,y4


def Boolean(p_target,p1,p2):
	if p1<p_target<p2:
		return True
	else:
		return False


def solve(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
	#????§???¢a????????????
	xa3,ya3,xa4,ya4=other_point(xa1,ya1,xa2,ya2)
	#????§???¢b????????????
	xb3,yb3,xb4,yb4=other_point(xb1,yb1,xb2,yb2)
	

	#xb1????????????xa1,xa2??????????????????????????§???yb1????????????ya1,ya2?????????????????????
	#??¨
	#xb2????????????xa1,xa2??????????????????????????§???yb???????????????ya1,ya2?????????????????????
	#??¨
	#xb3????????????xa1,xa2??????????????????????????§???yb3????????????ya1,ya2?????????????????????
	#??¨
	#xb4????????????xa1,xa2??????????????????????????§ yb3????????????ya1,ya2?????????????????????
	#
	#????§????a,b?????????????????????????????????
	p1=Boolean(xb1,xa1,xa2) and Boolean(yb1,ya1,ya2)
	#print("p1",p1)
	p2=Boolean(xb2,xa1,xa2) and Boolean(yb2,ya1,ya2)
	#print("p2",p2)
	p3=Boolean(xb3,xa1,xa2) and Boolean(yb3,ya1,ya2)
	#print("p3",p3)
	p4=Boolean(xb4,xa1,xa2) and Boolean(yb4,ya1,ya2)
	#print("p4",p4)
	
	p5=Boolean(xa1,xb1,xb2) and Boolean(ya1,yb1,yb2)
	#print("p5",p5)
	p6=Boolean(xa2,xb1,xb2) and Boolean(ya2,yb1,yb2)
	#print("p6",p6)
	p7=Boolean(xa3,xb1,xb2) and Boolean(ya3,yb1,yb2)
	#print("p7",p1)
	p8=Boolean(xa4,xb1,xb2) and Boolean(ya4,yb1,yb2)
	#print("p8",p8)

	if (p1 or p2 or p3 or p4) or (p5 or p6 or p7 or p8):
		print("YES")
	else:
 		print("NO")


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

Submission status: Wrong Answer

Solution code:
def other_point(x1,y1,x2,y2):
	x3,y3,x4,y4=x1,y2,x2,y1
	return x3,y3,x4,y4


def Boolean(p_target,p1,p2):
	if p1<=p_target<=p2:
		return True
	else:
		return False


def solve(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
	#????§???¢a????????????
	xa3,ya3,xa4,ya4=other_point(xa1,ya1,xa2,ya2)
	#????§???¢b????????????
	xb3,yb3,xb4,yb4=other_point(xb1,yb1,xb2,yb2)
	

	#xb1????????????xa1,xa2??????????????????????????§???yb1????????????ya1,ya2?????????????????????
	#??¨
	#xb2????????????xa1,xa2??????????????????????????§???yb???????????????ya1,ya2?????????????????????
	#??¨
	#xb3????????????xa1,xa2??????????????????????????§???yb3????????????ya1,ya2?????????????????????
	#??¨
	#xb4????????????xa1,xa2??????????????????????????§ yb3????????????ya1,ya2?????????????????????
	#
	#????§????a,b?????????????????????????????????
	p1=Boolean(xb1,xa1,xa2) and Boolean(yb1,ya1,ya2)
	#print("p1",p1)
	p2=Boolean(xb2,xa1,xa2) and Boolean(yb2,ya1,ya2)
	#print("p2",p2)
	p3=Boolean(xb3,xa1,xa2) and Boolean(yb3,ya1,ya2)
	#print("p3",p3)
	p4=Boolean(xb4,xa1,xa2) and Boolean(yb4,ya1,ya2)
	#print("p4",p4)
	
	p5=Boolean(xa1,xb1,xb2) and Boolean(ya1,yb1,yb2)
	#print("p5",p5)
	p6=Boolean(xa2,xb1,xb2) and Boolean(ya2,yb1,yb2)
	#print("p6",p6)
	p7=Boolean(xa3,xb1,xb2) and Boolean(ya3,yb1,yb2)
	#print("p7",p1)
	p8=Boolean(xa4,xb1,xb2) and Boolean(ya4,yb1,yb2)
	#print("p8",p8)

	if (p1 or p2 or p3 or p4) or (p5 or p6 or p7 or p8):
		print("YES")
	else:
 		print("NO")


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
while True:
    try:
        ls=list(map(float,input().split(' ')))
        xok=(ls[0]<=ls[4] and ls[4]<=ls[2])or(ls[0]<=ls[6] and ls[6]<=ls[2])
        yok=(ls[1]<=ls[5] and ls[5]<=ls[3])or (ls[1]<=ls[7] and ls[7]<=ls[3])
        if xok and yok:print('YES')
        else :print('NO')
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        ls=list(map(float,input().split(' ')))
        xok=(ls[0]<=ls[4] and ls[4]<=ls[2])or(ls[0]<=ls[6] and ls[6]<=ls[2])or(ls[4]<=ls[0] and ls[2]<=ls[6])
        yok=(ls[1]<=ls[5] and ls[5]<=ls[3])or (ls[1]<=ls[7] and ls[7]<=ls[3])or(ls[5]<=ls[1] and ls[3]<=ls[7])
        if xok and yok:print('YES')
        else :print('NO')
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        ls=list(map(float,input().split(' ')))
        xok=(ls[0]<=ls[4] and ls[4]<=ls[2])or (ls[0]<=ls[6] and ls[6]<=ls[2])or(ls[4]<=ls[0] and ls[0]<=ls[6])
        yok=(ls[1]<=ls[5] and ls[5]<=ls[3])or (ls[1]<=ls[7] and ls[7]<=ls[3])or(ls[5]<=ls[1] and ls[1]<=ls[7])
        if xok and yok:print('YES')
        else :print('NO')
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        ls=list(map(float,input().split(' ')))
        xok=(ls[0]<=ls[4] and ls[4]<=ls[2])or(ls[4]<=ls[0] and ls[0]<=ls[6])
        yok=(ls[1]<=ls[5] and ls[5]<=ls[3])or(ls[5]<=ls[1] and ls[1]<=ls[7])
        if xok and yok:print('YES')
        else :print('NO')
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        ls=list(map(float,input().split(sep=' ')))
        xok=(ls[0]<=ls[4] and ls[4]<=ls[2])or (ls[0]<=ls[6] and ls[6]<=ls[2])or(ls[4]<=ls[0] and ls[2]<=ls[6])
        yok=(ls[1]<=ls[5] and ls[5]<=ls[3])or (ls[1]<=ls[7] and ls[7]<=ls[3])or(ls[5]<=ls[1] and ls[3]<=ls[7])
        if xok and yok:print('YES')
        else :print('NO')
    except:
        break

Submission status: Wrong Answer

Solution code:
while 1:
    try:ax, ay, bx, by, cx, cy, dx, dy = map(float, input().split())
    except:break
    print(['YES','NO'][ay>dy or cy>by])

Submission status: Wrong Answer

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

import sys
import os

for s in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, s.split())

    # B in A
    if xa1 <= xb1 <= xa2 or xa1 <= xb2 <= xa2:
        b_in_a_x = True
    else:
        b_in_a_x = False

    if ya1 <= yb1 <= ya2 or ya1 <= yb2 <= ya2:
        b_in_a_y = True
    else:
        b_in_a_y = False

    # A in B
    if xb1 <= xa1 <= xb2 or xb1 <= xa2 <= xb2:
        a_in_b_x = True
    else:
        a_in_b_x = False

    if yb1 <= ya1 <= yb2 or yb1 <= ya2 <= yb2:
        a_in_b_y = True
    else:
        a_in_b_y = False

    if b_in_a_x and b_in_a_y:
        print('YES')
    elif a_in_b_x and a_in_b_y:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin:
    if line == "\n":
        break
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split())
    if xb1 <= xa1 <= xb2 and yb1 <= ya1 <= yb2\
    or xb1 <= xa2 <= xb2 and yb1 <= ya2 <= yb2\
    or xa1 <= xb1 <= xa2 and ya1 <= yb1 <= ya2\
    or xa1 <= xb2 <= xa2 and ya1 <= yb2 <= ya2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        dx = abs((xa2 - xa1) - (xb2 - xb1))
        dy = abs((ya2 - ya1) - (yb2 - yb1))
        w = (xa2 - xa1)/2 + (xb2 - xb1)/2
        h = (ya2 - ya1)/2 + (yb2 - yb1)/2
        if dx <= w or dy <= h:
            print("YES")
        else:
            print("NO")
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        dx = abs((xa2 + xa1)/2 - (xb2 + xb1)/2)
        dy = abs((ya2 + ya1)/2 - (yb2 + yb1)/2)
        w = (xa2 - xa1)/2 + (xb2 - xb1)/2
        h = (ya2 - ya1)/2 + (yb2 - yb1)/2
        if dx <= w or dy <= h:
            print("YES")
        else:
            print("NO")
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        dx = abs((xa2 + xa1)/2 - (xb2 + xb1)/2)
        dy = abs((ya2 + ya1)/2 - (yb2 + yb1)/2)
        w = (xa2 - xa1)/2 + (xb2 - xb1)/2
        h = (ya2 - ya1)/2 + (yb2 - yb1)/2
        if dx <= w and dy <= h:
            print("YES")
        else:
            print("NO")
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        dx = abs((xa2 + xa1)/2 - (xb2 + xb1)/2)
        dy = abs((ya2 + ya1)/2 - (yb2 + yb1)/2)
        w = (xa2 - xa1)/2 + (xb2 - xb1)/2
        h = (ya2 - ya1)/2 + (yb2 - yb1)/2
        if dx < w and dy < h:
            print("YES")
        else:
            print("NO")
    except:
        break

Submission status: Wrong Answer

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

N = list(get_input())
for l in range(len(N)):
    xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = [float(i) for i in N[l].split()]
    if ((xb1 <= xa1 and xa1 <= xb2) or (xb1 <= xa2 and xa2 <= xb2)) \
                and ((yb1 <= ya1 and ya1 <= yb2) or (yb1 <= ya2 and ya2 <= yb2)):
        print("YES")
    elif ((xa1 <= xb1 and xb1 <= xa2) or (xa1 <= xb2 and xb2 <= xa2)) \
                and ((ya1 <= yb1 and yb1 <= ya2) or (ya1 <= yb2 and yb2 <= ya2)):
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
while True:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=map(float,input().split())
    except EOFError:
        break
    flag=0
    if (xa1<=xb1 and xb1<=xa2) and (ya1<=yb1 and yb1<=ya2):#左下が入っている
        flag=1
    if (xa1<=xb2 and xb2<=xa2) and (ya1<=yb1 and yb1<=ya2):#右下が入っている
        flag=1
    if (xa1<=xb1 and xb1<=xa2) and (ya1<=yb2 and yb2<=ya2):#左上が入っている
        flag=1
    if (xa1<=xb2 and xb2<=xa2) and (ya1<=yb2 and yb2<=ya2):#右上が入っている
        flag=1
    if flag==0:
        print("NO")
    else:
        print("YES")

Submission status: Wrong Answer

Solution code:
import sys
def ov(l):
    if((l[5]<=l[3]<=l[7] or l[5]<=l[1]<=l[7]) and (l[4]<=l[0]<=l[6] or l[4]<=l[2]<=l[6])): return True
    if((l[4]<=l[0]<l[2]<=l[6]) and (l[5]<=l[1]<l[3]<=l[7])): return True
    if((l[0]<=l[4]<l[6]<=l[2]) and (l[1]<=l[5]<l[7]<=l[3])): return True
    return False
[print(l) for l in ["YES" if ov(i) else "NO" for i in [list(map(float,j.split())) for j in sys.stdin]]]

Submission status: Wrong Answer

Solution code:
import sys
def ov(l):
    if((l[5]<=l[3]<=l[7] or l[5]<=l[1]<=l[7]) and (l[4]<=l[0]<=l[6] or l[4]<=l[2]<=l[6])): return True
    if((l[1]<=l[5]<=l[3] or l[1]<=l[7]<=l[3]) and (l[0]<=l[4]<=l[2] or l[0]<=l[6]<=l[2])): return True
    if((l[4]<=l[0]<l[2]<=l[6]) and (l[5]<=l[1]<l[3]<=l[7])): return True
    if((l[0]<=l[4]<l[6]<=l[2]) and (l[1]<=l[5]<l[7]<=l[3])): return True
    return False
[print(l) for l in ["YES" if ov(i) else "NO" for i in [list(map(float,j.split())) for j in sys.stdin]]]

Submission status: Wrong Answer

Solution code:
import sys
def solve(line):
    xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=map(float, line.split())
    a=[[(xa1,ya1),(xa2,ya1)],[(xa2,ya1),(xa1,ya2)],[(xa1,ya2),(xa2,ya2)],[(xa2,ya2),(xa1,ya1)]]
    b=[[(xb1,yb1),(xb2,yb1)],[(xb2,yb1),(xb1,yb2)],[(xb1,yb2),(xb2,yb2)],[(xb2,yb2),(xb1,yb1)]]
    for [(x1, y1),(x2,y2)] in a:
        for [(x3, y3),(x4,y4)] in b:
            dinominator=((x2-x1)*(y4-y3)-(y2-y1)*(x4-x3))
            if dinominator==0: continue
            r=((y4-y3)*(x3-x1)-(x4-x3)*(y3-y1))/dinominator
            s=((y2-y1)*(x3-x1)-(x2-x1)*(y3-y1))/dinominator
            if 0<r<=1 and 0<s<=1: return 'YES'
    return 'NO'

for line in sys.stdin.readlines():
    print solve(line)

Submission status: Wrong Answer

Solution code:
import sys
def solve(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
    if xa1<=yb1 and yb1<=ya2 and xb1<=xa2 and ya1<=yb2:
        return 'YES'
    return 'NO'

for line in sys.stdin.readlines():
    f=map(float, line.split())
    print solve(*f)

Submission status: Wrong Answer

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
    elif xb1 <= xa2 <= xb2 and yb1 <= ya2 <= yb2:
        return True
    # the case A's lowerr left point in B
    elif xb1 <= xa1 <= xb2 and yb1 <= ya1 <= yb2:
        return True
    # the case A's lowerr right point in B
    elif 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

Submission status: Wrong Answer

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
    elif xb1 <= xa2 <= xb2 and yb1 <= ya2 <= yb2:
        return True
    # the case A's lowerr left point in B
    elif xb1 <= xa1 <= xb2 and yb1 <= ya1 <= yb2:
        return True
    # the case A's lowerr right point in B
    elif xb1 <= xa2 <= xb2 and yb1 <= ya1 <= yb2:
        return True
    else:
        return False

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

Submission status: Wrong Answer

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
    elif xb1 <= xa2 <= xb2 and yb1 <= ya2 <= yb2: return True
    # the case A's lowerr left point in B
    elif xb1 <= xa1 <= xb2 and yb1 <= ya1 <= yb2: return True
    # the case A's lowerr right point in B
    elif xb1 <= xa2 <= xb2 and yb1 <= ya1 <= yb2: return True
    # the case B's upper left point in A
    elif xa1 <= xb1 <= xa2 and ya1 <= yb2 <= ya2: return True
    # the case B's upper rihgt point in A
    elif xa1 <= xb2 <= xa2 and ya1 <= yb2 <= ya2: return True
    # the case B's lowerr left point in A
    elif xa1 <= xb1 <= xa2 and ya1 <= yb1 <= ya2: return True
    # the case B's lowerr right point in A
    elif xa1 <= xb2 <= xa2 and ya1 <= yb1 <= ya2: return True
    else: return False

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

Submission status: Wrong Answer

Solution code:
def Check(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
    if xb1 <= xa1 <= xb2 and (yb1 <= ya1 <= yb2 or yb1 <= ya2 <= yb2): return True
    if xb1 <= xa2 <= xb2 and (yb1 <= ya1 <= yb2 or yb1 <= ya2 <= yb2): return True
    if xa1 <= xb1 <= xa2 and (ya1 <= yb1 <= ya2 or ya1 <= yb2 <= ya2): return True
    if xa1 <= xb2 <= xa2 and (ya1 <= yb1 <= ya2 or ya1 <= yb2 <= ya2): return True
    return False

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

Submission status: Wrong Answer

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 < ya1) else "YES"
    except:
        break

Submission status: Accepted

Solution code:
import sys
for x1, y1, x2, y2, x3, y3, x4, y4 in (map(float, l.split()) for l in sys.stdin.readlines()):
    a = sorted([((x1, y1), (x2, y2)), ((x3, y3), (x4, y4))])
    b = sorted(a, key=lambda x: x[0][1])
    if a[0][1][0] >= a[1][0][0] and b[0][1][1] >= b[1][0][1]:
        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())
  print ["YES","NO"][any([c<e,g<a,d<f,h<b])]

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

# a1が左下、a2が右上とされている事がポイント
for line in f:
    xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float, line.split())
    print('NO'  if xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < yb1 else 'YES')

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#memo roiti 886942
while 1:
    try:
        xa,ya,xb,yb,xc,yc,xd,yd=map(float,raw_input().split())
        print 'NO' if (xd<xa or xb<xc or yd<ya or yb<yc) else 'YES'
    except:
        break

Submission status: Accepted

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


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

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 p[0].x > p[3].x or p[1].x < p[2].x or p[0].y > p[3].y or p[1].y < p[2].y:
        print "NO"
    else:
        print "YES"

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    try:
        ls=list(map(float,input().split()))
        xok=(ls[0]<=ls[4] and ls[4]<=ls[2])or (ls[0]<=ls[6] and ls[6]<=ls[2])or(ls[4]<=ls[0] and ls[2]<=ls[6])
        yok=(ls[1]<=ls[5] and ls[5]<=ls[3])or (ls[1]<=ls[7] and ls[7]<=ls[3])or(ls[5]<=ls[1] and ls[3]<=ls[7])
        if xok and yok:print('YES')
        else :print('NO')
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float,input().split())
        if xb2 < xa1 or xa2 < xb1:
            print("NO")
        elif yb1 > ya2 or ya1 > yb2:
            print("NO")
        else:
            print("YES")
    except EOFError:
        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:print(['NO','YES'][ay<=dy and cy<=by])
    else:print('NO')

Submission status: Accepted

Solution code:
while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    except EOFError:
        break

    if (x4 < x1 or x2 < x3) or (y4 < y1 or y2 < y3):
        print('NO')
    else:
        print('YES')

Submission status: Accepted

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

import sys
import os

for s in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, s.split())

    if xb2 < xa1 or xa2 < xb1 or ya2 < yb1 or yb2 < ya1:
        print('NO')
    else:
        print('YES')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

def intersect1d(a, b, c, d):
    return a <= d and b >= c

def intersect(xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2):
    return intersect1d(xa1, xa2, xb1, xb2) and intersect1d(ya1, ya2, yb1, yb2)

def main():
    for line in sys.stdin:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split())
        print("YES" if intersect(xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2) else "NO")

if __name__ == "__main__": main()

Submission status: Accepted

Solution code:
# Aizu Problem 0059: Intersection of Rectangles
#
import sys, math, os, bisect

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


def overlap(x1, y1, x2, y2, x3, y3, x4, y4):
    if y3 > y2 or y4 < y1:
        return False
    if x4 < x1 or x3 > x2:
        return False
    return True

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

Submission status: Accepted

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

Submission status: Accepted

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

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(['YES','NO'][c<e or g<a or d<f or h<b])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def ov(l):
    if (abs(l[0]+l[2]-l[4]-l[6])<=(l[2]-l[0]+l[6]-l[4]) and abs(l[1]+l[3]-l[5]-l[7])<=(l[3]-l[1]+l[7]-l[5])): return True
    return False
[print(l) for l in ["YES" if ov(i) else "NO" for i in [list(map(float,j.split())) for j in sys.stdin]]]

Submission status: Accepted

Solution code:
# AOJ 0059: Intersection of Rectangles
# Python3 2018.6.28 bal4u

def inside(x, y, xl, yd, xr, yu):
	return xl <= x and x <= xr and yd <= y and y <= yu

def judge(xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2):
	if inside(xb1, yb1, xa1, ya1, xa2, ya2): return True
	if inside(xb2, yb1, xa1, ya1, xa2, ya2): return True
	if inside(xb2, yb2, xa1, ya1, xa2, ya2): return True
	if inside(xb1, yb2, xa1, ya1, xa2, ya2): return True

	if inside(xa1, ya1, xb1, yb1, xb2, yb2): return True
	if inside(xa2, ya1, xb1, yb1, xb2, yb2): return True
	if inside(xa2, ya2, xb1, yb1, xb2, yb2): return True
	if inside(xa1, ya2, xb1, yb1, xb2, yb2): return True

	if xb1 <= xa1 and xa1 <= xb2 and xb1 <= xa2 and xa2 <= xb2 and \
	   ya1 <= yb1 and ya2 >= yb2: return True
	if xa1 <= xb1 and xb1 <= xa2 and xa1 <= xb2 and xb2 <= xa2 and \
	   yb1 <= ya1 and yb2 >= ya2: return True
	return False

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

	if xa1 > xa2: xa1, xa2 = xa2, xa1
	if ya1 > ya2: ya1, ya2 = ya2, ya1
	if xb1 > xb2: xb1, xb2 = xb2, xb1
	if yb1 > yb2: yb1, yb2 = yb2, yb1
	print("YES" if judge(xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2) 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]
    if x[1]<x[2] or x[0]>x[3] or y[1]<y[2] or y[0] > y[3]:print "NO"
    else:print "YES"

Submission status: Accepted

Solution code:

import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.strip().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: 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:
    gen = (float(s) for s in line.split())
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = gen

    if xa1 > xb2 or xa2 < xb1:
        print('NO')
    elif ya1 > yb2 or ya2 < yb1:
        print('NO')
    else:
        print('YES')

Submission status: Accepted

Solution code:
import sys
def solve(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2):
    if xa2 < xb1 or xb2 < xa1 or ya2 < yb1 or yb2 < ya1:
        return 'NO'
    return 'YES'

for line in sys.stdin.readlines():
    f=map(float, line.split())
    print solve(*f)

Submission status: Accepted

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