Atlantis
InterviewTime limit1sMemory limit128 MB
Given up to 100 axis-aligned rectangles, compute the area of their union and print it with two decimals.
- Level
Medium7 of 10
- Topics
- Geometry, Segment tree, Prefix sum, Sorting
- Solved
- No attempts yet
Problem
Several ancient Greek texts contain descriptions of the fabled island of Atlantis. Some of these texts even include maps of parts of the island, but unfortunately these maps describe different regions of Atlantis. Your friend Bill needs to know the total area for which maps exist. You have volunteered to write a program that computes this quantity.
Input
The input consists of several test cases. Each test case begins with a line containing a single integer (), the number of available maps. Each of the following lines describes one map with four numbers , , , (; ), not necessarily integers. The pair is the top-left corner and is the bottom-right corner of the mapped rectangular area.
The input is terminated by a line containing a single , which must not be processed.
Output
For each test case, print two lines. The first line must be Test case #k, where is the number of the test case (starting from ). The second line must be Total explored area: a, where is the total explored area — that is, the area of the union of all rectangles in the test case — printed with exactly two digits after the decimal point.
Print a single blank line between consecutive test cases.