#P16694. [CSPro 29] 田地丈量
[CSPro 29] 田地丈量
Background
Luogu’s testdata is only for community communication and is not official testdata. Official judging link: https://www.cspro.org/.
Problem Description
On Xixi Aifu Island, there are fields scattered around. Each field can be viewed as a rectangular region on the Cartesian plane, uniquely determined by the bottom-left corner and the top-right corner , with and . Among these fields, the intersection area of any two fields is ; they may only overlap on their boundaries.
Recently, Dundun wants to reclaim a rectangular field of area at the foot of Nanshan Mountain, with bottom-left corner and top-right corner . Compute the total area of the existing fields that lies within Dundun’s chosen region.
Input Format
Read input from standard input.
There are lines in total.
The first line contains three positive integers , , and 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 lines each contain four integers , , , and 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.
4 10 10
0 0 5 5
5 -2 15 3
8 8 15 15
-2 10 3 15
44
Hint
Sample Explanation
As shown in the figure, the area of fields within the chosen region (the green area) is .
:::align{center}
:::
Subtasks
All testdata satisfy , and the absolute value of every input coordinate does not exceed .
Translated by ChatGPT 5