QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 2048 MB Points totaux : 100

#2431. 抢先打击犯罪

Statistiques

你的朋友罗宾(Robin)是一位超级英雄。当你第一次发现这一点时,你心想:“每个人都需要一个爱好,这看起来比集邮刺激多了。”但现在你真的很庆幸有人在你的家乡打击犯罪。

每天晚上,罗宾都会通过在屋顶之间跳跃来巡逻城市,并观察下方发生的事情。自然地,超级英雄需要立即响应危机,所以罗宾向你寻求帮助,以弄清楚如何快速穿梭于家乡。

你的家乡建立在一个方形网格上,每个街区的大小为 $w \times w$ 米。每个街区都有一栋建筑。这些建筑的高度可能不同(见图 E.1)。要从一栋建筑到达另一栋(不一定相邻)建筑,罗宾会从第一栋建筑的屋顶中心跳到第二栋建筑的屋顶中心。罗宾在空中时不能改变方向,但可以选择起跳的角度。

图 E.1:对应第一个样例输入的建筑横截面。黑色部分为建筑,从 (1, 1) 的屋顶到 (4, 1) 的屋顶的跳跃用绿线表示。

当然,罗宾只想在不与任何建筑发生碰撞的情况下进行跳跃。这种碰撞对超级英雄造成的伤害很小,但当有人撞破窗户时,业主往往会感到恼火。你向罗宾解释了物理原理:“你所有的跳跃都以相同的初速度 $v$ 进行,它具有指向目的地的水平分量 $v_d$ 和向上的垂直分量 $v_h$,因此 $v_d^2 + v_h^2 = v^2$。当你移动时,你的水平速度保持不变 ($v_d(t) = v_d$),但你的垂直速度受重力影响 ($v_h(t) = v_h - t \cdot g$),其中 $g = 9.80665 \text{ m/s}^2$ 是你家乡的重力加速度。”

自然地,你的斗篷让你忽略了空气阻力的影响。这使你可以确定你的飞行路径,然后……”此时你注意到罗宾已经睡着了——少点数学,多点超级英雄行为!

所以任务落到了你身上:给定城市的布局和罗宾秘密基地的位置,你需要确定罗宾可以到达哪些建筑的屋顶,以及到达每个屋顶所需的最少跳跃次数。

注意,如果罗宾的跳跃经过建筑的角落(四栋建筑交汇处),那么跳跃高度需要高于所有四栋相邻建筑。

输入格式

输入的第一行包含六个整数 $d_x, d_y, w, v, \ell_x, \ell_y$。它们分别代表城市网格的大小 $d_x \times d_y$($1 \le d_x, d_y \le 20$,单位为街区)、每个建筑的宽度 $w$($1 \le w \le 10^3$,单位为米)、罗宾的起跳速度 $v$($1 \le v \le 10^3$,单位为米/秒),以及罗宾秘密基地的坐标 $(\ell_x, \ell_y)$($1 \le \ell_x \le d_x, 1 \le \ell_y \le d_y$)。

第一行之后是城市网格中建筑高度的描述。描述包含 $d_y$ 行,每行包含 $d_x$ 个非负整数。第 $j$ 行包含建筑 $(1, j), (2, j), \dots, (d_x, j)$ 的高度。所有高度均以米为单位,且最大不超过 $10^3$。

输出格式

显示罗宾从秘密基地到达每栋建筑屋顶所需的最少跳跃次数。如果无法到达某栋建筑的屋顶,则显示 X 而不是跳跃次数。按照输入文件中给出的顺序显示建筑,分为 $d_y$ 行,每行包含 $d_x$ 个值。

你可以假设将任何建筑的高度改变最多 $10^{-6}$ 不会改变答案。

样例

样例输入 1

4 1 100 55 1 1
10 40 60 10

样例输出 1

0 1 1 1

样例输入 2

4 4 100 55 1 1
0 10 20 30
10 20 30 40
20 30 200 50
30 40 50 60

样例输出 2

0 1 1 2
1 1 1 2
1 1 X 2
2 2 2 3

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.