Combining Rectangles
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given N rectangles with sides aligned to the coordinate axes, your task is to calculate the area of the shape formed by the union of these rectangles.
Keep in mind that the resulting shape may consist of separate parts.
Input
The first line contains the integer N (1 ≤ N ≤ 100), representing the number of rectangles. The following N lines each contain 4 integers: x_1, y_1, x_2, y_2, which are the coordinates of two opposite corners of a rectangle. The coordinates are integers and can range up to 10000 in absolute value.
Output
Output the total area of the figure formed by the union of the rectangles.
Explanation for example 1:
Examples
Input #1
Answer #1
Submissions 521
Acceptance rate 19%