QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#3481. 汽车

統計

你是一名在领先的自动驾驶汽车公司 Wayber 工作的工程师。Wayber 刚刚获得瑞典政府批准,可以在斯德哥尔摩的街道上行驶。不幸的是,你目前所有的测试都是在封闭的土路上一次只测试一辆车。你还没有准备好应对两辆车在城市中相遇的情况,因此需要编写一些代码来处理这个问题。

这些汽车已经能够很好地保持在车道内行驶和转弯,但在检测其他移动车辆方面表现不佳。幸运的是,瑞典政府对自动驾驶汽车非常热衷,他们已经禁止了斯德哥尔摩所有其他形式的交通工具,包括人工驾驶汽车、自行车和步行。如果你能检测出两辆车是否会发生碰撞,你就能构建一个安全的系统。

你知道所有的城市都只由南北向和东西向的街道组成,形成一个完美的网格,且所有的汽车都是完美的矩形棱柱。在检测碰撞时,你只需要考虑汽车在不转弯的情况下以恒定速度行驶的情况。

图 B.1:样例输入 1 的示意图。

输入格式

输入的第一行包含一个整数 $1 \le t \le 10^4$,表示两辆车轨迹的持续时间(以秒为单位)。接下来是两辆车的轨迹描述。

轨迹由一行组成,包含一个字符 $d$ 和五个整数 $x, y, s, w$ 和 $l$。汽车的起始位置为 $(x, y)$ ($0 \le x, y \le 10^4$),其行驶方向 $d$ 为 $\text{N}$($y$ 轴正方向)、$\text{S}$($y$ 轴负方向)、$\text{W}$($x$ 轴负方向)或 $\text{E}$($x$ 轴正方向)。汽车的行驶速度为 $1 \le s \le 10^4$ 单位/秒,宽度为 $1 \le w \le 10^4$ 单位,长度为 $1 \le l \le 10^4$ 单位。

汽车从其起始坐标中心开始行驶,且初始时不会在非零面积上重叠。

输出格式

对于每一行输入,如果两辆车会发生碰撞,输出一行 “crash”;如果不会发生碰撞,则输出 “safe”。如果两辆车在面积为零的区域重叠(仅在边缘或角落接触),则它们不会发生碰撞。

样例

输入 1

5
E 0 0 2 1 2
S 3 2 1 1 3

输出 1

crash

输入 2

1
E 0 0 1 1 1
N 0 2 1 1 1

输出 2

safe

输入 3

2
N 0 0 7 3 1
S 3 20 12 4 1

输出 3

crash

输入 4

1
N 0 0 7 3 1
S 3 20 12 4 1

输出 4

safe

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.