P29203 [洛谷] [MCOI-05] Slime
提高+
题目描述

Background

On July 7, 2077, MineCraft 20.7.7 was released. This update allowed players to etch redstone circuits into a circuit board for computation.

As a programmer and MC player, namespace_std wanted to build a simple slime block shield machine using the new version's circuit board.

However, namespace_std hadn't played MC for too long and built the TNT duplication device incorrectly, resulting in being blasted into outer space. Therefore, the task of constructing this slime block shield machine was handed over to the bookworm.

The bookworm, with his liver of durability X, wrote the program for this shield machine. However, things are not that simple...

Problem Description

The bookworm has a $1 \times 1$ volume shield machine and a $n \times m$ grid field. The bookworm plans to use the shield machine to flatten this field. Formally, the bookworm needs to make the shield machine pass through each grid exactly once.

This seems simple. However, there is a glitch in the implementation of the shield machine's program. When the shield machine moves continuously in the same direction for $k$ steps, it will get stuck and continuously drop TNT in the same place.

Note: The initial placement of the shield machine does not count as movement. In other words, the shield machine should move $n \times m - 1$ times.

The bookworm does not want to end up like the poor namespace_std being blasted into the sky, so he hopes to find a route arrangement for the shield machine that will not cause it to get stuck.

Input Format

Input consists of three integers $n, m, k$ on a single line, representing the length and width of the field, and the $k$ value in the shield machine's program, respectively.

Output Format

If there is a valid solution, output three lines:

  • The first line outputs the string YES;
  • The second line outputs a string of length $n \times m - 1$ containing only L, R, D, U, representing the direction of each move;
  • The third line outputs two integers $x, y$, indicating that the starting point of the bookworm's designed route is $(x, y)$, i.e., the $x$-th row and $y$-th column. When there are multiple possible answers, the bookworm can output any one.

Otherwise, output only one line NO.

Please note that the output may be large, please use a fast output method.

Sample Input and Output

Sample Input #1

3 3 2

Sample Output #1

NO

Sample Input #2

3 3 3

Sample Output #2

YES
RDLDRRUU
1 1

Sample Input #3

6 4 4

Sample Output #3

YES
RRRDLLLDRRRDLLLDRRRDLLL
1 1

Sample Input #4

1 1 2000

Sample Output #4

YES

1 1

Notes

Data Size and Constraints

This problem uses batched testing.

  • Subtask 0 (1 pts): Examples, you can find out if your answer passes the Special Judge by submitting the results.
  • Subtask 1 (9 pts): $n, m, k \leq 3$.
  • Subtask 2 (15 pts): $n, m, k \leq 10$.
  • Subtask 3 (5 pts): $k \geq n$.
  • Subtask 4 (15 pts): $n \leq 5$.
  • Subtask 5 (20 pts): $k \geq 5$.
  • Subtask 6 (10 pts): A valid solution is guaranteed to exist.
  • Subtask 7 (25 pts): No special restrictions.

For $100\%$ of the data, $1 \le n, m, k \le 2000$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 2
样例输出
NO