QOJ.ac

QOJ

Süre Sınırı: 1 s Bellek Sınırı: 64 MB Toplam puan: 100

#23196. 彩纸

İstatistikler

将 $N$ 张颜色各不相同的长方形彩纸,按顺序一张一张地放在平面上。 

彩纸不会斜着放置。也就是说,所有彩纸的边之间要么平行,要么垂直。 

图 1 展示了依次放上 1、2、3 号三张彩纸后的状态。

 

problem_23196_00b389f7b25e3479ad975c889c4e4882.png

 

如果如图 2 所示再放上一张 4 号彩纸,3 号彩纸就会被完全遮住而看不见。 

此时 1 号和 2 号彩纸被部分遮住,而 4 号彩纸完全可见。

 

problem_23196_3a5e2bb653337d502a674da446b5959c.png

 

编写程序,当 $N$ 张彩纸按顺序放在给定位置时,求每张彩纸可见部分的面积。

 

输入格式

输入第一行给出整数 $N$($1 \le N \le 100$),表示彩纸张数。接下来 $N$ 行按顺序描述每张彩纸,每张占一行。

放置彩纸的平面是一个水平方向最多 $1001$ 格、竖直方向最多 $1001$ 格的网格。 

网格的每个格子都是宽为 $1$、高为 $1$、面积为 $1$ 的正方形。 

为方便说明,以水平方向 $6$ 格、竖直方向 $6$ 格的网格为例。每个格子中标出的值 $(a, b)$ 表示该格子的编号。 

最左下方的格子是 $(0, 0)$,最右上方的格子是 $(5, 5)$。

problem_23196_daeca5fa2fe213bb1a63990b319437c9.png

彩纸的放置状态用四个整数表示,分别给出其最左下方格子的编号、宽度和高度。 

例如,上图灰色彩纸最左下方的格子是 $(1, 4)$,宽为 $3$,高为 $2$,因此表示为 `1 4 3 2`。 

彩纸不会超出网格边界。 

数据范围 

子任务 1:占总分 $100$ 分中的 $11$ 分,$N = 1$。 

子任务 2:占总分 $100$ 分中的 $12$ 分,$N \le 10$,所有彩纸的宽和高都为 $1$。平面是水平方向 $101$ 格、竖直方向 $101$ 格的网格。 

子任务 3:占总分 $100$ 分中的 $30$ 分,$N \le 10$,平面是水平方向 $101$ 格、竖直方向 $101$ 格的网格。 

子任务 4:占总分 $100$ 分中的 $47$ 分,除原有数据范围外无其他限制。

输出格式

按输入顺序在平面上放好 $N$ 张彩纸后,按输入顺序输出每张彩纸可见部分的面积,每行输出一个整数。

如果某张彩纸不可见,则输出整数 $0$。

样例

输入格式 1

2
0 0 10 10
2 2 6 6

输出格式 1

64
36

输入格式 2

3
0 2 10 10
7 9 8 4 
8 4 10 6

输出格式 2

81
25
60

输入格式 3

4
0 2 10 10 
7 9 8 4 
8 4 10 6
6 0 12 10

输出格式 3

62
24
0
120

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.