1033: Rectangle Area
[Creator : ]
Description
Given a set of rectangles { R1, R2, ... Rn }, compute the area of their common intersection i.e. :
Area( $ R1 \cap R2 \cap R3 .... \cap Rn $ }
The edges of the rectangle R1, R2, ... Rn are either vertical or horizontal lines
For example, the intersection of the 4 rectangles in the following example is the shaded rectangle:
Area( $ R1 \cap R2 \cap R3 .... \cap Rn $ }
The edges of the rectangle R1, R2, ... Rn are either vertical or horizontal lines
For example, the intersection of the 4 rectangles in the following example is the shaded rectangle:
Input
The first line specifies the number of rectangles n, where 1 < n < 1,000. Since the
sides of the rectangles are parallel to the x and y axes, each rectangle is bounded by
the lines x = x1, x = x2, y = y1 and y = y2 and each subsequent line of the input thus specifies one rectangle in the following format:
x1 x2 y1 y2
such that 0 <= x1 < x2 <= 10,000 and 0 <= y1 < y2 <= 10,000 and x1, x2, y1, y2 are all integers.
Output
The output file contains the area of the intersection of all the rectangles.
Sample Input Copy
2
0 2 0 2
1 3 1 3
Sample Output Copy
1