Boxes and Holes

View as PDF

Submit solution

Points: 3
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type

You are given 2 objects, and you're trying to figure out collisions!

You might be given 2 rectangles, and you want to know if the rectangles overlap or not.

You might also be given 2 circles, and you want to know if the circles overlap or not.

Constraints

1 \leq r,l,w \leq 10^6

-10^6 \leq x,y,h,k \leq 10^6

Input Specifications

The first line of input will be a string that is either circle or rectangle.

If the first line is circle, there will be 2 lines of input, with each line containing space-separated integers h,k,r, a circle with center (h,k) and radius r.

If the first line is rectangle, there will be 2 lines of input, with each line containing space-separated integers x,y,l,w, a rectangle with bottome left corner (x,y), length (horizontally) l and width (vertically) w.

Output Specifications

If the first line of input is circle, output overlapping if the circles overlap (including tangency!), or non-overlapping if the circles are not overlapping.

If the first line of input is rectangle, output overlapping if the rectangles overlap (including touching on the edges or corners!), or non-overlapping if the rectangles are not intersecting.

Sample Input 1

circle
0 0 5
6 8 5

Sample Output 1

overlapping

Explanation for Sample Output 1

It can be shown that the only point where these circles intersect is at (3,4). Thus, the two circles are intersecting.

Sample Input 2

rectangle
0 0 2 2
2 2 4 4

Sample Output 2

overlapping

Explanation for Sample Output 2

It can be shown that the only point where these rectangles intersect is at (2,2). Thus, the two rectangles are intersecting.


Comments

There are no comments at the moment.