#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 nn fields scattered around. Each field can be viewed as a rectangular region on the Cartesian plane, uniquely determined by the bottom-left corner (x1,y1)(x_1, y_1) and the top-right corner (x2,y2)(x_2, y_2), with x1<x2x_1 < x_2 and y1<y2y_1 < y_2. Among these nn fields, the intersection area of any two fields is 00; they may only overlap on their boundaries.

Recently, Dundun wants to reclaim a rectangular field of area a×ba \times b at the foot of Nanshan Mountain, with bottom-left corner (0,0)(0, 0) and top-right corner (a,b)(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+1n + 1 lines in total.

The first line contains three positive integers nn, aa, and bb 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 nn lines each contain four integers x1x_1, y1y_1, x2x_2, and y2y_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.

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 4444.

:::align{center} :::

Subtasks

All testdata satisfy n≤100n \le 100, and the absolute value of every input coordinate does not exceed 10410^4.

Translated by ChatGPT 5