QOJ.ac

QOJ

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

#4997. 垃圾之旅

الإحصائيات

你是 MALL-E,商场里的滑板车收集机器人。你一天的工作是在商场关门后收集所有乱放的滑板车,并将它们送回滑板车存放点。商场是一个无限大的网格,其中有 $n$ 辆需要归还的滑板车。你可以向四个方向之一移动:上、下、左或右,每次移动耗时一秒。如果你移动到的位置包含一辆滑板车,该滑板车会向你移动的方向移动到下一个位置。如果滑板车移动到的位置包含另一辆滑板车,则会发生同样的情况,因此每个位置上永远不会超过一辆滑板车,且你永远不会与滑板车占据相同的位置。如果滑板车移动到了存放点,它就会消失。不过,机器人可以自由地在存放点上方移动。

商场很快就要开门了。你需要找到一种方法,在最多 $10^5$ 秒内将所有滑板车送回存放点。

样例 2 的示意图。最左侧的两辆滑板车可以通过向上移动三次、向右移动两次推入存放点。

输入格式

输入的第一行包含一个整数 $n$ ($1 \le n \le 50$)。下一行包含四个整数 $x_0, y_0, x_t$ 和 $y_t$ ($0 \le x_0, y_0, x_t, y_t \le 30$)。这表示你起始于 $(x_0, y_0)$,存放点位于 $(x_t, y_t)$。接下来有 $n$ 行,每行包含两个整数 $x$ 和 $y$ ($0 \le x, y \le 30$)。这表示有一辆滑板车位于 $(x, y)$。你、存放点以及所有滑板车的位置各不相同。

输出格式

输出应包含一系列指令,每行一条。指令是以下字符串之一:“up”、“down”、“left” 或 “right”。

样例

样例输入 1

1
0 0 2 0
1 0

样例输出 1

right

样例输入 2

8
1 1 4 4
5 4
6 4
3 4
2 4
4 5
4 6
4 3
4 2

样例输出 2

up
up
up
right
right
down
down
down
right
up
up
right
right
right
up
left
left
up
up
up
left
down
down

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.