QOJ.ac

QOJ

时间限制: 4 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#17971. 智能仓库

统计

Hyundai AutoEver 是一家引领未来出行创新的公司,正在变革第四次工业革命中的智能物流范式。

Hyundai AutoEver 正在测试一个智能仓库,其中的物品摆放成一个 $N \times M$ 的网格。我们将从上往下数第 $r$ 行、从左往右数第 $c$ 列的单元格记为 $(r, c)$。每个单元格 $(r, c)$ 中都有一个物品,其价值为 $A_{rc}$。物品的价值可以为负数。

仓库中的机器人有时会收到将某个物品运送出去的指令。为了提高运输效率,机器人也可以将附近的物品作为一个矩形区域一起运送。具体来说,假设机器人收到运送单元格 $(r, c)$ 处物品的指令。在这种情况下,机器人会选择四个整数 $r_1$,$r_2$,$c_1$,$c_2$,满足 $1 \le r_1 \le r \le r_2 \le N$ 且 $1 \le c_1 \le c \le c_2 \le M$,然后运送矩形区域 $[r_1, r_2] \times [c_1, c_2]$ 内的所有物品。

对于这 $NM$ 个物品中的每一个,计算当机器人收到运送该物品的指令时,能够运送的物品价值总和的最大值。

输入格式

输入的第一行包含两个空格分隔的整数 $N$ 和 $M$,表示仓库的大小。($2 \le N \le 500$;$2 \le M \le 500$)

接下来的 $N$ 行中,第 $r$ 行包含 $M$ 个空格分隔的整数 $A_{r1}$, $A_{r2}$, $\cdots$, $A_{rM}$,对应网格中第 $r$ 行每个物品的价值。($-10^3 \le A_{rc} \le 10^3$)

输出格式

共输出 $N$ 行。在输出的第 $r$ 行中,打印 $M$ 个整数,表示当机器人收到运送单元格 $(r, 1)$, $(r, 2)$, $\cdots$, $(r, M)$ 处的物品指令时,能够运送的物品价值总和的最大值。

样例

输入样例 1

3 4
2 2 2 2
2 -8 0 -12
2 -8 7 5

输出样例 1

8 8 9 8 
6 1 9 4 
6 6 12 12

输入样例 2

2 2
-1 -3
2 -1

输出样例 2

1 -3 
2 1

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.