QOJ.ac

QOJ

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

#18539. 超光速

Statistics

在电子游戏《超越光速》(Faster Than Light)中,每艘太空飞船都可以表示在一个平面网格上。网格的所有单元格都是单位正方形。某些单元格代表飞船的舱段,可以对其进行射击。其他单元格则不属于飞船。

游戏中有一种光束武器,其射击方式如下:发射时,该武器会在被攻击的飞船上用光束画出一道长度固定为 $L$ 的线段。线段的位置可以任意选择,前提是其一端必须位于被攻击飞船的某个舱段内部或边界上。线段的另一端可以位于任何地方,包括网格外部。飞船及其船员受到的伤害取决于被光束损坏的舱段集合。如果线段与某个舱段单元格(包括其边界)至少有一个公共点,则认为该飞船舱段已被损坏。

请你编写一个瞄准程序,其工作方式如下:对于每艘太空飞船,给出击中其每个舱段所能获得的正积分。你的程序必须找到线段的位置,使得所有被损坏舱段的分数之和最大。

输入格式

输入的第一行包含两个整数 $N$ 和 $M$,分别表示网格的行数和列数($1 \le N, M \le 30$)。

第二行包含线段的长度——一个实数 $L$,小数点后最多保留两位数字($0.1 \le L \le 50$)。

接下来的 $N$ 行描述网格。其中每行包含 $M$ 个整数。设这些行中第 $i$ 行的第 $j$ 个数字为 $a_{ij}$($0 \le a_{ij} \le 10^7$,$i = 1 \dots N$,$j = 1 \dots M$)。如果 $a_{ij} = 0$,则表示相应的单元格为空。如果 $a_{ij} > 0$,则表示该单元格包含一个飞船舱段,击中它可获得 $a_{ij}$ 分。

保证网格中至少存在一个包含飞船舱段的单元格。不同的飞船舱段之间可能是不连通的。

输出格式

输出必须包含一个整数,表示单次发射光束所能获得的最大可能得分。

样例

输入样例 1

5 4
2.5
1 0 5 1
3 0 3 5
0 0 0 0
1 8 1 3
1 3 1 2

输出样例 1

23

说明

样例测试允许以如下方式发射武器:使其同时击中两个 5 分单元格、1 分和 3 分单元格,以及 8 分和 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.