QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#6431. 糟糕,又是昨天重现

统计

在 2021 年的比赛中,Paimon 为你准备了该问题的另一个版本。你将得到一个 $n$ 行 $n$ 列的网格($2 \le n \le 500$)。所有单元格均为空,且每个单元格中都站着一只袋鼠。

同样,你可以通过按下键盘上的 U、D、L、R 键来控制袋鼠。袋鼠会根据你按下的按钮同时移动。具体来说,对于位于第 $i$ 行第 $j$ 列(记为 $(i, j)$)的任意袋鼠:

  1. 按钮 U:如果 $i > 1$,它将移动到 $(i - 1, j)$。否则,它将停留在原位。
  2. 按钮 D:如果 $i < n$,它将移动到 $(i + 1, j)$。否则,它将停留在原位。
  3. 按钮 L:如果 $j > 1$,它将移动到 $(i, j - 1)$。否则,它将停留在原位。
  4. 按钮 R:如果 $j < n$,它将移动到 $(i, j + 1)$。否则,它将停留在原位。

你需要构造一个仅由字符 ‘U’、‘D’、‘L’ 和 ‘R’ 组成的操作序列。在执行该序列后,必须确保每一只袋鼠都聚集在指定的单元格 $(a, b)$。操作序列的长度不能超过 $3(n - 1)$。

输入格式

每个测试文件中仅包含一组测试数据。

输入的第一行也是唯一一行包含三个整数 $n, a, b$($2 \le n \le 500, 1 \le a, b \le n$),分别表示网格的大小和目标单元格。

输出格式

输出一行,包含一个仅由字符 ‘U’、‘D’、‘L’ 和 ‘R’ 组成的字符串。其长度不得超过 $3(n - 1)$。可以证明答案总是存在的。

样例

样例输入 1

3 3 3

样例输出 1

RRDD

样例输入 2

4 3 2

样例输出 2

DLDLDLUR

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.