Rect | 프로그래밍의 벗 PivotOJ
PivotOJ

Rect

시간 제한: 2000ms메모리 제한: 512MB출처: NOI 2007BOJ 9849
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Given a set of rectangles {R1, R2, · · · , Rn}, compute the area of their common intersection. i.e.,

Area (R1 ∩ R2 ∩ · · · ∩ Rn)

The edges of the rectangles R1, R2, · · · , Rn, are either vertical or horizontal lines.

For example, the intersection of 4 rectangles, R1, R2, R3, and R4, in the following figure is the shaded rectangle.

[이미지 1]

입력

T.IN 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 and y2 are int

출력

The output contains the area of the intersection of all the rectangles.

예제

예제 1

입력
2
0 2 0 2
1 3 1 3
출력
1

예제 2

입력
3
1 4 1 8
0 2 0 5
10 15 22 35
출력
0
코드를 제출하려면 로그인하세요.