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.