#C3749. Rectangles Overlap
Rectangles Overlap
Rectangles Overlap
Given two axis-aligned rectangles, determine whether they overlap. The first rectangle is defined by its lower-left corner \((x_1, y_1)\) and upper-right corner \((x_2, y_2)\), and the second rectangle is defined by its lower-left corner \((x_3, y_3)\) and upper-right corner \((x_4, y_4)\). Two rectangles are considered to be overlapping if and only if the intersection of their interiors has a positive area. Note that if the rectangles only touch along an edge or at a corner, they are not considered to overlap.
The condition for overlap can be mathematically expressed as:
[ \max(x_1, x_3) < \min(x_2, x_4) \quad \text{and} \quad \max(y_1, y_3) < \min(y_2, y_4) ]
If both conditions hold, output "YES"; otherwise, output "NO".
inputFormat
The input consists of a single line containing eight space-separated integers: \(x_1\), \(y_1\), \(x_2\), \(y_2\), \(x_3\), \(y_3\), \(x_4\), \(y_4\). It is guaranteed that for each rectangle, the first two numbers represent the coordinates of the lower-left corner and the next two numbers represent the coordinates of the upper-right corner.
outputFormat
Output a single line containing either "YES" if the rectangles overlap, or "NO" otherwise.
## sample0 0 2 2 1 1 3 3
YES