407080: GYM102697 051 The Convergence of Two Tetra-sided Polygons, Known as Rectangles

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

051. The Convergence of Two Tetra-sided Polygons, Known as Rectanglestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You will be given two opposite corners of two separate rectangles and you must determine whether they intersect or not.

Input

The first line will contain 4 integers separated by spaces, which respectively represent the x-coordinate and y-coordinate of a corner of the rectangle and the x-coordinate and y-coordinate of the opposite corner. The second line will contain another 4 integers that represent the same coordinates but for the second rectangle.

Output

Print "YES" (without the quotes) if the rectangles intersect or "NO" (without the quotes) if the rectangles do not intersect.

ExampleInput
-5 -5 5 5
4 4 8 8
Output
YES
Note

The first rectangle has one corner located at (-5,-5) and the opposite corner at (5,5). The second rectangle has one corner located at (4,4) and the opposite corner at (8,8). These rectangles intersect, thus "YES" is printed

Also, if the rectangles lie on top of one another, they are intersecting. If one is inside the other and their perimeters do not touch, then they are not intersecting.

加入题单

算法标签: