#P2692. 覆盖
覆盖
Description
The playground can be viewed as an -by- grid of cells. As shown in Figure (1), this is a -by- grid. Each boy is responsible for sweeping some consecutive rows, and each girl is responsible for sweeping some consecutive columns. For example, suppose there are two boys: the first boy is responsible for rows , and the second boy is responsible for row , shown in blue in Figure (2). The swept regions may overlap. For instance, suppose there are also two girls: the first girl is responsible for columns , and the second girl is responsible for columns , shown in red in Figure (3). From Figure (3), it is easy to see that the number of colored cells is 18, i.e., these four students have swept a total of 18 cells.

The teacher asks WSR to quickly compute, given the cleaning plan data, how many cells have been swept in total.
Input Format
The first line contains positive integers: . Here, is the number of rows, is the number of columns, is the number of boys, and is the number of girls.
The next lines each contain two integers . Each line indicates that a boy is responsible for rows through inclusive (a total of rows), with the guarantee that .
Then the next lines each contain two integers . Each line indicates that a girl is responsible for columns through inclusive (a total of columns), with the guarantee that .
Output Format
Output a single integer, the swept area (i.e., the total number of cells).
4 5 2 2
1 2
4 4
3 4
4 5
18
Hint
If you are not sure, try drawing a diagram yourself.
Constraints:
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号