#C11954. Rectangle Overlap
Rectangle Overlap
Rectangle Overlap
Given two rectangles on a 2D plane, determine whether they overlap.
The first rectangle is defined by its top-left corner (a, b) and bottom-right corner (c, d), and the second rectangle is defined by its top-left corner (a1, b1) and bottom-right corner (c1, d1). They are said to overlap if and only if all the following conditions hold:
\[ \begin{aligned} a &< c_1, \\ a_1 &< c, \\ b &< d_1, \\ b_1 &< d. \end{aligned} \]
Note: If the rectangles touch only at the edges or corners, they are considered not to be overlapping.
inputFormat
The input consists of a single line containing eight space-separated integers: a b c d a1 b1 c1 d1
.
Here:
- \(a, b\) and \(c, d\) are the coordinates of the top-left and bottom-right corners of the first rectangle respectively.
- \(a_1, b_1\) and \(c_1, d_1\) are the coordinates of the top-left and bottom-right corners of the second rectangle respectively.
outputFormat
Output a single line containing the string true
if the two rectangles overlap, otherwise output false
.
0 0 1 1 2 2 3 3
false
</p>