QOJ.ac

QOJ

时间限制: 7 s 内存限制: 512 MB 总分: 10

#2126. 高速公路 [B]

统计

特工卡罗尔(Karol)驾驶着他的红色汽车在一条三车道的高速公路上行驶。在他前方有一些其他车辆,每辆车都在各自的车道上以恒定的速度向前行驶:第 $i$ 条车道上的速度为 $v_i$(满足 $v_1 > v_2 > v_3$)。这些车辆既不会改变速度,也不会变道。卡罗尔可以立即变道至相邻车道。他也可以立即将自己的速度调整为不超过 $v_0$ 的任意实数($v_0 > v_1$)。他不能倒车,因此总是以 $[0, v_0]$ 区间内的速度向前行驶。

每辆车(包括卡罗尔的车)的长度均为 $1$。车辆之间可以接触,但卡罗尔不能导致碰撞,即不能产生正的重叠区域。形式化地,定义车辆的位置为车头到高速公路起点(即卡罗尔车头最初所在的位置)的距离。同一车道上两辆车的位置之差不能小于 $1$。请记住,其他车辆的速度是恒定的。

输入描述了高速公路上一段长度为 $L$ 的区域,卡罗尔目前位于第三条车道的起点。高速公路向后无限延伸,且在描述区域之外是空的。

计算卡罗尔超越所有其他车辆所需的最短时间。换句话说,确定在经过多长时间后,所有其他车辆都能完全位于卡罗尔车尾的后方——即它们的位置必须比卡罗尔的位置小至少 $1$。

输入格式

第一行包含五个整数 $L, v_0, v_1, v_2, v_3$($2 \le L \le 200\,000$;$1 \le v_3 < v_2 < v_1 < v_0 \le 140$)。

接下来的三行中,第 $i$ 行包含一个长度为 $L$ 的字符串 $s_i$,描述高速公路的第 $i$ 条车道。字符串 $s_i$ 的第 $j$ 个字符如果为 '#',则表示该位置有一辆车,否则为 '.'。

字符串 $s_1$ 和 $s_2$ 的第一个字符为 '.',而 $s_3$ 的第一个字符为 '#',表示特工卡罗尔的汽车。输入中总共至少有两个 '#' 字符。

输入格式暗示所有车辆的初始位置均为整数。然而,卡罗尔可以在非整数时刻改变车道和速度,此时车辆的位置可能为非整数。

输出格式

输出一个实数,表示特工卡罗尔超越高速公路上所有车辆所需的最短时间。允许的相对或绝对误差为 $10^{-9}$。

形式化地说:如果精确结果为 $p$,则当满足 $|p - x| \le \max(1, p) \cdot 10^{-9}$ 时,你的答案 $x$ 将被接受。

样例

样例输入 1

5 60 15 10 9
.#...
..#.#
###..

样例输出 1

0.644444444444444

样例输入 2

6 140 120 115 110
.##...
......
#.#.#.

样例输出 2

0.166666666666667

说明

第一个样例的解释:

卡罗尔的车显然是红色的。

特工卡罗尔立即从第三车道变道至第二车道,并立即从第二车道变道至第一车道。

他行驶在第一车道上,紧跟在速度为 $v_1 = 15$ 的车辆后面,直到他超越了第二车道上的两辆车中的第一辆。

他从第一车道变道至第二车道,并立即从第二车道变道至第三车道。

他以最大速度 $v_0 = 60$ 行驶,直到超越所有车辆。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.