QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 2048 MB Puntuación total: 100

#15863. 海上漂流

Estadísticas

你正在为帆船开发一个导航系统,但遗憾的是,普通的导航系统由于几个原因无法工作。首先,像“向左转”这样的指令是毫无意义的,因为海上没有路。此类指令必须附带旋转的角度(以度为单位)。此外,在航海导航中不使用“左”和“右”。相反,“port”(左舷)和“starboard”(右舷)分别用于表示“左”(逆时针)和“右”(顺时针)。

图片由 ElfQrin 提供。CC BY-SA 3.0

给定帆船当前的航向和期望的航向,你的任务是提供一条转向期望航向的指令。所有航向均由 8 个罗盘方向给出:N、NE、E、SE、S、SW、W、NW。在此列表中,每个方向都比前一个方向顺时针旋转 45 度。除了转向之外,指令也可能是“Keep going straight”(保持直行)或“U-turn”(掉头,即向相反方向行驶)。你可以假设转向是瞬间完成的。

输入格式

输入包含两行。第一行是当前的航向,第二行是期望的航向。所有航向均为上述 8 个罗盘方向之一。

输出格式

输出单行,为以下三种形式之一:

  • Keep going straight
  • U-turn
  • Turn d degrees dir

在最后一种情况下,$d$ 应为 $1$ 到 $179$ 之间的整数,且 $dir$ 应为单词 portstarboard

样例

输入样例 1

N
S

输出样例 1

U-turn

输入样例 2

NW
NW

输出样例 2

Keep going straight

输入样例 3

N
SW

输出样例 3

Turn 135 degrees port

输入样例 4

N
E

输出样例 4

Turn 90 degrees starboard

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.