QOJ.ac

QOJ

Límite de tiempo: 8 s Límite de memoria: 1024 MB Puntuación total: 47

#5886. 巡航控制

Estadísticas

定速巡航系统允许汽车以恒定速度行驶,而驾驶员只需控制方向盘。当然,驾驶员可以关闭定速巡航以避免碰撞。

在本题中,我们考虑一条有两条车道的单向道路,共有 $N$ 辆使用定速巡航的汽车。每辆车长 5 米,并以恒定速度行驶。如果换道不会导致与其他车辆发生碰撞(接触不算碰撞),汽车可以随时换道。假设换道是瞬间完成的,且仅导致汽车切换到另一条车道。我们感兴趣的是,是否有驾驶员最终必须关闭定速巡航以避免碰撞,或者所有车辆是否都有可能无限期地行驶(可以换道,但保持恒定速度)而不发生碰撞。注意,尽管换道是瞬间完成的,但两辆并排驾驶的汽车不能通过同时换道来交换位置。

输入格式

输入文件的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例以汽车数量 $N$ 开始。随后有 $N$ 行,每行描述一辆车。每行包含一个字符 $C_i$(表示汽车初始位于左车道还是右车道)、两个整数分别表示汽车的速度 $S_i$(单位:米/秒)和初始位置 $P_i$(单位:米,表示车尾与道路上某条固定线之间的距离)。所有汽车都在远离该线行驶,且没有汽车位于该线后方。

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是用例编号(从 1 开始),$y$ 要么是单词 "Possible"(仅为清晰起见加引号,表示汽车可以无限期地以给定的恒定速度行驶),要么是某人必须改变速度以避免碰撞前所能行驶的最长时间(以秒为单位)。绝对或相对误差在 $10^{-5}$ 以内的答案将被接受。

数据范围

$1 \le T \le 30$。

$1 \le S_i \le 1000$。

$0 \le P_i \le 10000$。

每个 $C_i$ 字符要么是 $L$(表示左车道),要么是 $R$(表示右车道)。

初始时,汽车的位置不会发生碰撞,即如果两辆车 $i$ 和 $j$ 的初始车道相同(即 $C_i = C_j$),则 $|P_i - P_j| \ge 5$。

子任务 1

$1 \le N \le 6$。

子任务 2

$1 \le N \le 50$。

样例

样例输入 1

4
2
L 5 10
L 100 0
3
L 100 0
R 100 0
L 50 505
6
L 30 0
R 30 2
L 10 39
R 10 42
L 25 13
L 15 29
4
L 4 0
L 2 29
L 1 35
L 1 44

样例输出 1

Case #1: Possible
Case #2: 10.0
Case #3: 1.4
Case #4: 12.0

说明

在第一个案例中,较快的车可以换到右车道并轻松超越较慢的车。在第二个案例中,两辆以 100 m/s 并排行驶的汽车将在 10 秒后追上以 50 m/s 行驶的汽车,由于两条车道都将被堵塞,有人将不得不改变速度。

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.