QOJ.ac

QOJ

حد الوقت: 4.0 s حد الذاكرة: 2048 MB مجموع النقاط: 100

#15943. 首尾相接的交通

الإحصائيات

这是晚高峰时期的缓慢爬行。在任何时间点,每辆车要么处于静止状态,要么以每秒 1 米的极慢速度行驶。最近,车辆都配备了一个简单的“黑匣子”,用于记录车辆速度的所有变化。在本题中,速度的变化是瞬时发生的。

道路被建模为实数轴(单位为米)。因此,一辆车的位置由它在数轴上的位置来确定。此外,车身长度为 4.4 米。

给定两辆沿数轴正方向行驶的汽车的初始位置以及它们速度变化的记录,这两辆车是否发生过碰撞?虽然这种碰撞的速度非常慢(即“轻微追尾”),但任何碰撞都可能导致黑匣子在之后的记录中出现错误,因此碰撞发生后的记录部分可能没有实际意义。

Photo by mckay savage cc by-sa 2.0

输入格式

输入只有一组测试数据。

第一行包含两个整数 $0 \le X_1, X_2 \le 10^6$,表示两辆车尾部在数轴上的初始位置(单位:米)。保证 $X_1 + 5 \le X_2$ 或 $X_2 + 5 \le X_1$。初始时(在时刻 0),两辆车都处于静止状态。

第二行以一个整数 $0 \le N_1 \le 10^5$ 开始,表示第一辆车速度发生变化的次数。该行的其余部分包含 $N_1$ 个整数 $0 < T_1 < T_2 < \dots < T_{N_1} \le 10^6$,表示第一辆车改变速度的时间(单位:秒)。因此,在时刻 $T_1$ 它开始以 1 m/s 的速度行驶,在时刻 $T_2$ 它停止,在时刻 $T_3$ 它又开始以 1 m/s 的速度行驶,依此类推。

最后一行以一个整数 $0 \le N_2 \le 10^5$ 开始,后面跟着 $N_2$ 个整数 $0 < T'_1 < T'_2 < \dots < T'_{N_2} \le 10^6$,描述第二辆车启动和停止的时间。

输出格式

如果两辆车发生碰撞,则在单行中输出 bumper tap at time S,其中 $S$ 是从时刻 0 开始到两辆车首次发生碰撞的时间(秒),向上取整到最接近的整数秒。如果两辆车没有发生碰撞,则在单行中输出 safe and sound

样例

输入样例 1

0 5
3 1 4 5
3 1 4 6

输出样例 1

bumper tap at time 6

输入样例 2

10 0
2 1 2
1 1

输出样例 2

bumper tap at time 8

输入样例 3

2 13
1 1
3 4 7 10

输出样例 3

safe and sound

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.