QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100

#18533. 大床

Statistics

在遙遠星系中的 Nibiru 星球上,最有前途的學生之一 Basilius 獲得了著名的 Nibiru 國立大學(NSU)的特別獎學金。他決定為自己的宿舍房間買一張床。

他希望床的體積盡可能大,但另一方面,未來這張床的尺寸也有限制——Basilius 想在房間裡留些空間,用來放置他以後購物的戰利品。

當地商店可以製作任何長方體形狀的床。然而,並不是所有床都能從商店運到宿舍房間。床必須搬過一些傳送門,它們看起來就像我們常見的長方形門。傳送門與地板垂直。穿過一個傳送門會到達其他一些傳送門附近,或到達一個房間。請幫助 Basilius 計算適合他房間的最佳床尺寸。傳送門之間的距離遠大於宿舍房間的尺寸。

假設床的朝向使某個固定的面始終與地板平行,另一個固定的面則與目前傳送門所在的平面平行。

床一旦被抬起、開始穿過傳送門搬往房間,就不會再旋轉。

輸入格式

輸入檔案第一行包含三個整數 $a$、$b$ 和 $c$,用來限制床的尺寸。長、寬、高中的一個不得超過 $a$,另一個不得超過 $b$,剩下的一個不得超過 $c$($1\le a,b,c\le 500$)。

下一行包含一個整數 $n$,表示星球上傳送門的數量($2\le n\le 500$)。傳送門從 $1$ 到 $n$ 編號。商店裡的傳送門編號為 $1$,通往 Basilius 房間的傳送門編號為 $n$。

接下來 $n$ 行描述 Nibiru 的傳送門,每行一個。其中第 $i$ 行描述第 $i$ 個傳送門,開頭是三個以空格分隔的實數 $w_i$、$h_i$ 和 $k_i$。前兩個數表示傳送門的寬度和高度,第三個數表示穿過該傳送門後可以直接到達的傳送門數量($1\le w_i,h_i\le 300$,$0\le k_i<n$)。接著是 $k_i$ 個兩兩不同的整數 $p_{ij}$,表示從第 $i$ 個傳送門可以直接到達的傳送門編號($1\le p_{ij}\le n$,$p_{ij}\ne i$)。

輸出格式

輸出檔案必須包含三個正整數 $x,y,z$,順序任意,表示 Basilius 可以從商店搬到宿舍房間的床中,體積最大的床的尺寸。如果有多種體積最大的方案,輸出任意一種。保證本題存在解。

範例

輸入格式 1

300 300 300
4
300 300 1 2
100 200 1 4
300 200 1 1
300 300 2 3 1

輸出格式 1

100 200 300

輸入格式 2

300 300 300
4
300 300 2 2 3
100 200 1 4
300 200 1 4
300 300 1 1

輸出格式 2

200 300 300

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.