QOJ.ac

QOJ

Süre Sınırı: 10 s Bellek Sınırı: 256 MB Toplam puan: 100

#23826. 魚的棲息範圍

İstatistikler

在澳洲大陸的西側,是一望無際的印度洋。身為海洋研究員的 JOI 先生正在研究棲息於印度洋中的某 $N$ 種魚的性質。

對於每種魚,在海中都有一個固定的長方體狀棲息範圍。魚可以移動到包含邊界在內的棲息範圍中的任何位置,但絕不會跑到棲息範圍之外。海中的點由 $3$ 個實數 $(x, y, d)$ 表示:$(x, y, d)$ 表示從高空俯瞰時,以某個地點為基準向東前進 $x$、向北前進 $y$ 的位置,且距離海面的深度為 $d$ 的點。在此假設海面為一個平面。

JOI 先生想知道有多少地方是 $K$ 種以上的魚的棲息範圍重疊的。請撰寫一個程式,求出所有這類地方的總體積。

輸入格式

輸入由 $1 + N$ 行組成。

第 $1$ 行包含以空白分隔的 $2$ 個整數 $N, K$ ($1 \le K \le N \le 50$)。這表示魚有 $N$ 種,且想要求出 $K$ 種以上的魚的棲息範圍重疊之處的體積。

接下來的 $N$ 行中的第 $i$ 行 ($1 \le i \le N$) 包含 $6$ 個整數 $X_{i,1}, Y_{i,1}, D_{i,1}, X_{i,2}, Y_{i,2}, D_{i,2}$ ($0 \le X_{i,1} < X_{i,2} \le 1000000 \ (= 10^6)$,$0 \le Y_{i,1} < Y_{i,2} \le 1000000 \ (= 10^6)$,$0 \le D_{i,1} < D_{i,2} \le 1000000 \ (= 10^6)$)。這表示第 $i$ 種魚的棲息範圍是以 $8$ 個點 $(X_{i,1}, Y_{i,1}, D_{i,1})$, $(X_{i,2}, Y_{i,1}, D_{i,1})$, $(X_{i,2}, Y_{i,2}, D_{i,1})$, $(X_{i,1}, Y_{i,2}, D_{i,1})$, $(X_{i,1}, Y_{i,1}, D_{i,2})$, $(X_{i,2}, Y_{i,1}, D_{i,2})$, $(X_{i,2}, Y_{i,2}, D_{i,2})$, $(X_{i,1}, Y_{i,2}, D_{i,2})$ 為頂點的長方體。

輸出格式

以 $1$ 行輸出 $K$ 種以上的魚的棲息範圍重疊之處的總體積。

範例

輸入格式 1

3 2
30 50 0 50 70 100
10 20 20 70 90 60
40 60 20 90 90 70

輸出格式 1

49000

說明

在範例 1 中,例如點 $(45, 65, 65)$ 是第 $1$ 種魚與第 $3$ 種魚的棲息範圍,因此是滿足條件的地方。另一方面,點 $(25, 35, 45)$ 僅是第 $2$ 種魚的棲息範圍,因此不是滿足條件的地方。此外,魚的棲息範圍如下圖所示。點 $O$ 表示海面上的基準點。

problem_23826_f3130890da3222c2e67bd94c2907d32a.png

輸入格式 2

1 1
0 0 0 1000000 1000000 1000000

輸出格式 2

1000000000000000000

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.