#abc318b. B - Overlapping sheets

B - Overlapping sheets

Score : 200200 points

问题描述

在坐标平面上铺有 NN 张矩形纸片。

每张纸片所覆盖的矩形区域的边都与 xx-轴或 yy-轴平行。 具体来说,第 ii 张纸片恰好覆盖满足 AixBiA_i \leq x\leq B_iCiyDiC_i \leq y\leq D_i 的区域。

SS 表示 被一个或多个纸片覆盖的区域 的面积。可以证明,在给定约束下,SS 是一个整数。 请以整数形式输出 SS

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN rectangular sheets spread out on a coordinate plane.

Each side of the rectangular region covered by each sheet is parallel to the xx- or yy-axis.
Specifically, the ii-th sheet covers exactly the region satisfying AixBiA_i \leq x\leq B_i and CiyDiC_i \leq y\leq D_i.

Let SS be the area of the region covered by one or more sheets. It can be proved that SS is an integer under the constraints.
Print SS as an integer.

Constraints

  • 2N1002\leq N\leq 100
  • 0Ai<Bi1000\leq A_i<B_i\leq 100
  • 0Ci<Di1000\leq C_i<D_i\leq 100
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 B1B_1 C1C_1 D1D_1

A2A_2 B2B_2 C2C_2 D2D_2

\vdots

ANA_N BNB_N CNC_N DND_N

Output

Print the area SS of the region covered by one or more sheets as an integer.

Sample Input 1

3
0 5 1 3
1 4 0 5
2 5 2 4

Sample Output 1

20

The three sheets cover the following regions.
Here, red, yellow, and blue represent the regions covered by the first, second, and third sheets, respectively.

Therefore, the area of the region covered by one or more sheets is S=20S=20.

Sample Input 2

2
0 100 0 100
0 100 0 100

Sample Output 2

10000

Note that different sheets may cover the same region.

Sample Input 3

3
0 1 0 1
0 3 0 5
5 10 0 10

Sample Output 3

65

update @ 2024/3/10 09:04:18