QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#23196. 色紙

Statistics

將 $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.