QOJ.ac

QOJ

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

#22320. 造湖

Statistics

Farmer John 想讓牛幫造湖。牧場為 $R$ 行($3\le R\le100$)、$C$ 欄($3\le C\le100$),每格六英尺乘六英尺,平均高度以英吋計($10\le elev_{rc}\le5000$)。

訓練牛「踩踏挖土」,強壯牛群恰覆蓋 $3\times3$ 格,至左上角 $R_s,C_s$($1\le R_s\le R-2;1\le C_s\le C-2$),踩低 $D_s$ 英吋($1\le D_s\le40$)。低處牛等其他牛降到自己高度才開始踩,故未必九格都踩,或某些踩較少。

給初始高度、有序 $N$ 指令($1\le N\le20000$)與最終水位 $E$($0\le E\le5000$),求立方英吋容積,答案不超 $2,000,000,000$。邊緣有障壁,水不溢出。

$4\times6$ 牧場初始高度,標行欄:

| 行/欄 | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $28$ | $25$ | $20$ | $32$ | $34$ | $36$ | | $2$ | $27$ | $25$ | $20$ | $20$ | $30$ | $34$ | | $3$ | $24$ | $20$ | $20$ | $20$ | $20$ | $30$ | | $4$ | $20$ | $20$ | $14$ | $14$ | $20$ | $20$ |

右上丘高 $36$,左上小丘高 $28$,第 $4$ 行中稍凹。執行 "$1\;4\;4$" 後:

| 行 | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $28$ | $25$ | $20$ | $32$ | $32$ | $32$ | | $2$ | $27$ | $25$ | $20$ | $20$ | $30$ | $32$ | | $3$ | $24$ | $20$ | $20$ | $20$ | $20$ | $30$ | | $4$ | $20$ | $20$ | $14$ | $14$ | $20$ | $20$ |

只三格踩低,其餘六處等踩者降至自己高度卻沒等到。再 "$1\;1\;10$" 踩左上後:

| 行 | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $18$ | $18$ | $18$ | $32$ | $32$ | $32$ | | $2$ | $18$ | $18$ | $18$ | $20$ | $30$ | $32$ | | $3$ | $18$ | $18$ | $18$ | $20$ | $20$ | $30$ | | $4$ | $20$ | $20$ | $14$ | $14$ | $20$ | $20$ |

最終水位 $22$ 英吋時深度:

| 行 | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $4$ | $4$ | $4$ | -- | -- | -- | | $2$ | $4$ | $4$ | $4$ | $2$ | -- | -- | | $3$ | $4$ | $4$ | $4$ | $2$ | $2$ | -- | | $4$ | $2$ | $2$ | $8$ | $8$ | $2$ | $2$ |

深度合計 $66$,乘六英尺乘六英尺面積,$66\times72\times72=342,144$ 立方英吋,邊長 $72$ 英吋。

寫程式自動計算。

輸入格式

  • 第 $1$ 行:空格分隔 $R,C,E,N$。

  • 第 $2,\ldots,R+1$ 行:第 $i+1$ 行給第 $i$ 行 $C$ 空格分隔整數。

  • 第 $R+2,\ldots,R+N+1$ 行:第 $i+R+1$ 行是指令 $i$ 的 $R_s,C_s,D_s$。

輸出格式

  • 第 1 行:整數,新湖立方英吋容積。

範例

輸入格式 1

4 6 22 2
28 25 20 32 34 36
27 25 20 20 30 34
24 20 20 20 20 30
20 20 14 14 20 20
1 4 4
1 1 10

輸出格式 1

342144

說明

如正文範例。

題目作者:Rob Kolstad,2008 年

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.