#K90992. Determine Rectangle Overlap

    ID: 37875 Type: Default 1000ms 256MiB

Determine Rectangle Overlap

Determine Rectangle Overlap

Given two axis-aligned rectangles in a 2D plane, your task is to determine if they overlap. The first rectangle is defined by its bottom-left corner (x1, y1) and top-right corner (x2, y2), and the second rectangle is defined by its bottom-left corner (x3, y3) and top-right corner (x4, y4).

Two rectangles are considered to overlap if they share a positive area in common. Formally, if the overlapping area, given by the intersection of the two rectangles, satisfies \[ (x_{\text{overlap}}) > 0 \quad \text{and} \quad (y_{\text{overlap}}) > 0, \] then the rectangles overlap. Note that if they only touch along their edges or corners, they are not considered overlapping.

Your program should read eight integers from standard input representing the coordinates in the order:

  • x1 y1 x2 y2 x3 y3 x4 y4

Output OVERLAP if the rectangles overlap and NO OVERLAP otherwise.

inputFormat

The input consists of a single line containing eight space-separated integers:

x1 y1 x2 y2 x3 y3 x4 y4

where:

  • (x1, y1) and (x2, y2) are the coordinates of the bottom-left and top-right corners of the first rectangle, respectively.
  • (x3, y3) and (x4, y4) are the coordinates of the bottom-left and top-right corners of the second rectangle, respectively.

outputFormat

Output a single line to standard output containing either OVERLAP if the rectangles share a positive area, or NO OVERLAP if they do not.

## sample
0 0 2 2 1 1 3 3
OVERLAP