QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 1024 MB Puntuación total: 100

#4684. 船舶交通

Estadísticas

往返于摩洛哥和西班牙之间,横跨直布罗陀海峡的渡轮必须小心航行,以避开海峡中繁忙的船运交通。请编写一个程序,帮助渡轮船长找到海峡交通中的最大间隙,以确保安全通行。

你的程序将使用以下简化模型:海峡有几条东西向的平行航道。船只以相同的恒定速度向东或向西行驶。同一航道上的所有船只方向相同。卫星数据提供了每条航道上船只的位置。船只的长度可能不同。船只不会变道,也不会为了渡轮而改变速度。

渡轮在船运交通出现足够间隙时等待合适的时机。然后,它以恒定的速度沿南北向航线横穿海峡。从渡轮进入某条航道的那一刻起,直到它离开该航道的那一刻止,该航道内的任何船只都不得触碰渡轮的航线。渡轮非常小,可以忽略其尺寸。图 I.1 展示了样例输入 1 的航道和船只情况。你的任务是找到渡轮可以安全横穿海峡的最大时间间隔。

图 I.1:样例输入 1。

输入格式

输入的第一行包含六个整数:航道数量 $n$ ($1 \le n \le 10^5$),每条航道的宽度 $w$ ($1 \le w \le 1000$),船只的速度 $u$ 和渡轮的速度 $v$ ($1 \le u, v \le 100$),渡轮的最早出发时间 $t_1$ 和最晚出发时间 $t_2$ ($0 \le t_1 < t_2 \le 10^6$)。所有长度单位为米,所有速度单位为米/秒,所有时间单位为秒。

接下来的 $n$ 行,每行包含一条航道的数据。每行以 E 或 W 开头,其中 E 表示该航道上的船只向东行驶,W 表示该航道上的船只向西行驶。接下来是一个整数 $m_i$,表示该航道上的船只数量(对于每个 $1 \le i \le n$,$0 \le m_i \le 10^5$)。随后是 $m_i$ 对整数 $l_{ij}$ 和 $p_{ij}$ ($1 \le l_{ij} \le 1000$ 且 $-10^6 \le p_{ij} \le 10^6$)。航道 $i$ 中第 $j$ 艘船的长度为 $l_{ij}$,$p_{ij}$ 是其在时间 0 时前端的位置,即其在行驶方向上的船头位置。

每条航道内的船只位置是相对于渡轮航线的。负位置表示在航线以西,正位置表示在航线以东。船只不会重叠或接触,并按位置递增顺序排列。航道按距离渡轮起点的距离递增排序,起点位于第一条航道正南侧。航道之间没有间隙。船只总数至少为 1,至多为 $10^5$。

输出格式

输出最大值 $d$,使得存在一个时间 $s$,渡轮可以在 $s \le t \le s + d$ 范围内的任意时间 $t$ 开始横穿。此外,横穿不得早于时间 $t_1$ 开始,且不得晚于时间 $t_2$ 开始。输出必须具有至少 $10^{-3}$ 的绝对或相对误差。你可以假设存在一个 $d > 0.1$ 秒的时间间隔供渡轮通行。

样例

样例输入 1

3 100 5 10 0 100
E 2 100 -300 50 -100
W 3 10 60 50 200 200 400
E 1 100 -300

样例输出 1

6.00000000

样例输入 2

1 100 5 10 0 200
W 4 100 100 100 300 100 700 100 900

样例输出 2

50.00000000

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.