#K43802. Overlapping Rectangles
Overlapping Rectangles
Overlapping Rectangles
You are given two rectangles in a 2D plane. Each rectangle is defined by its bottom-left corner and top-right corner. The coordinates are provided as 8 integers: the first 4 integers describe the first rectangle and the next 4 integers describe the second rectangle.
Determine if the two rectangles have a non-zero area of overlap. Two rectangles that only touch at their edges or corners are not considered overlapping.
The overlapping determination follows the mathematical condition:
Two rectangles do not overlap if one is completely to the left, right, above, or below of the other. In other words, let the first rectangle have corners at \((x1_1, y1_1)\) and \((x2_1, y2_1)\) and the second rectangle have corners at \((x1_2, y1_2)\) and \((x2_2, y2_2)\). Then they overlap if and only if:
\[ \max(x1_1, x1_2) < \min(x2_1, x2_2) \quad \text{and} \quad \max(y1_1, y1_2) < \min(y2_1, y2_2) \]Print "Yes" if they overlap and "No" otherwise.
inputFormat
The input consists of a single line with 8 space-separated integers:
x1_1 y1_1 x2_1 y2_1 x1_2 y1_2 x2_2 y2_2
These represent the coordinates of the bottom-left and top-right corners of the two rectangles respectively.
outputFormat
Output a single line containing either "Yes" if the rectangles overlap, or "No" otherwise.
## sample0 0 2 2 1 1 3 3
Yes
</p>