Carpets | 프로그래밍의 벗 PivotOJ
PivotOJ

Carpets

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2014-15 openBOJ 7190

문제

The fanciest hall of Prince Ville’s new castle has a rectangular floor. The walls of the hall run from North to South and from East to West. Ville’s advisors have proposed to cover some parts of the floor with carpets and even suggested a specific arrangement of them.

Ville, caring mostly only about the quantitative aspect of the deal, would like to know the total area covered by the carpets in the proposed arrangement.

입력

The first line of input contains three space-separated integers: the number of carpets KK (1 ≤ K ≤ 3), the distance LL from the East wall to the West wall (1 ≤ L ≤ 10^6), and the distance PP from the North wall to the South wall (1 ≤ P ≤ 10^6) of the hall. Each of the following KK lines contains four space-separated integers NN, SS, EE, and WW describing one carpet. The edges of the carpet are parallel to the walls and the numbers NN, SS, EE, and WW show, respectively, the distance of the North, South, East, and West edge of the carpet from the corresponding wall. The carpets may overlap partially or fully. All distances are given in metres.

출력

The only line of output should contain a single integer SS, the total area of the floor covered by carpets, in square metres.

예제

예제 1

입력
2 8 9
3 3 3 0
5 1 2 4
출력
20

예제 2

입력
3 5 5
3 1 1 3
1 3 3 1
3 1 3 1
출력
3
코드를 제출하려면 로그인하세요.