P16694 [CSPro 29] Field Measurement

Background

Luogu’s testdata is only for community communication and is not official testdata. Official judging link: .

Description

On Xixi Aifu Island, there are $n$ fields scattered around. Each field can be viewed as a rectangular region on the Cartesian plane, uniquely determined by the bottom-left corner $(x_1, y_1)$ and the top-right corner $(x_2, y_2)$, with $x_1 < x_2$ and $y_1 < y_2$. Among these $n$ fields, the intersection area of any two fields is $0$; they may only overlap on their boundaries. Recently, Dundun wants to reclaim a rectangular field of area $a \times b$ at the foot of Nanshan Mountain, with bottom-left corner $(0, 0)$ and top-right corner $(a, b)$. Compute the total area of the existing fields that lies within Dundun’s chosen region.

Input Format

Read input from standard input. There are $n + 1$ lines in total. The first line contains three positive integers $n$, $a$, and $b$ separated by spaces, representing the number of fields on Xixi Aifu Island and the coordinates of the top-right corner of Dundun’s chosen region. The next $n$ lines each contain four integers $x_1$, $y_1$, $x_2$, and $y_2$ separated by spaces, describing the position of one field.

Output Format

Write output to standard output. Output one integer, representing the area of fields within Dundun’s chosen region.

Explanation/Hint

### Sample Explanation As shown in the figure, the area of fields within the chosen region (the green area) is $44$. :::align{center} ![](https://cdn.luogu.com.cn/upload/image_hosting/zxdqsuci.png) ::: ### Subtasks All testdata satisfy $n \le 100$, and the absolute value of every input coordinate does not exceed $10^4$. Translated by ChatGPT 5