Problem 855
Rectangle Overlap
Easy · 10 pts · Math, Geometry
Problem
Two axis-aligned rectangles are given by their bottom-left corner (x1, y1) and top-right corner (x2, y2). Decide whether they overlap, meaning their intersection has a positive area. Rectangles that only touch along an edge or at a corner do not overlap. They overlap exactly when the overlap in X is positive (max of the left edges < min of the right edges) and the overlap in Y is positive too.
Input
The first line contains x1 y1 x2 y2 of the first rectangle. The second line contains those of the second rectangle.
Output
Print YES if the rectangles overlap with positive area, otherwise NO.
Constraints
-10^9 <= coordinates <= 10^9; x1 < x2 and y1 < y2 for both rectangles
Example input
0 0 2 2 1 1 3 3
Example output
YES
Explanation
The squares (0,0)-(2,2) and (1,1)-(3,3) share the square (1,1)-(2,2), which has area 1, so the answer is YES.