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.