Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

Panda 是一位谜题设计师,他决定设计一个基于“跟随箭头”主题的二维迷宫。这个迷宫是一个 $N$ 行 $M$ 列的网格。每个格子中都包含一个箭头:L(左)、R(右)、U(上)或 D(下)。

格子的索引为 $(x, y)$,其中 $x$ 是行号($1 \le x \le N$),$y$ 是列号($1 \le y \le M$)。左上角为 $(1, 1)$,右下角为 $(N, M)$。玩家从位置 $(1, 1)$ 开始,并按离散的步数进行移动,直到首次到达 $(N, M)$ 为止。每一步由以下两个按顺序执行的操作组成:

  • 1. 移动:向当前格子中箭头所指的方向移动一步。只有当尝试的移动会导致你走出迷宫时,你才会留在当前的格子中。
  • 2. 翻转:在步骤 1 的移动(或未移动)之后,你移动之前所在格子中的箭头会改变为相反的方向(即:L 变为 R,R 变为 L,U 变为 D,D 变为 U)。如果你没有移动,则翻转当前格子中的箭头。

Panda 想要设计一个最大尺寸为 $8 \times 8$ 的迷宫,使得玩家从 $(1, 1)$ 开始并遵循上述规则,恰好在 $k$ 步时到达 $(N, M)$。

输入格式

第一行包含一个整数 $T$($1 \le T \le 2 \times 10^4$),表示测试用例的数量。

每个测试用例包含一行,其中有一个整数 $k$($1 \le k \le 10^6$),表示玩家走出迷宫所需的步数。

保证所有测试用例中 $k$ 的总和不超过 $8 \times 10^7$。

输出格式

对于每个测试用例,如果无法设计出这样的迷宫,则在单行中输出 -1 -1

否则,首先输出一行,包含两个整数 $N, M$($1 \le N, M \le 8$),表示迷宫的大小。

接着输出 $N$ 行,每行包含 $M$ 个字符,表示迷宫。迷宫中的每个字符必须是 L、R、U、D 之一。

你必须确保从 $(1, 1)$ 到达 $(N, M)$ 所需的步数恰好为 $k$。

样例

输入样例 1

5
1
4
9
16
25

输出样例 1

1 2
RR
2 2
LU
RD
3 2
LU
DR
LL
3 2
LU
UR
LL
1 6
LLRLLR

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.