Universal Cup Judging System

Universal Cup

実行時間制限: 2.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

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.