#ABC474G. LRUD 移动 2 / LRUD Moving 2
LRUD 移动 2 / LRUD Moving 2
Problem Statement
You are given positive integers and .
There is an grid. The cell at the -th row from the top and the -th column from the left is denoted as cell .
Initially, a piece is placed on cell .
You will perform the following operation exactly times so that the piece ends up in cell :
- Move the piece one cell to a cell vertically or horizontally adjacent to the cell it is currently on.
Here, over the course of the movement, each of the cells must be visited exactly once. Cell , where the piece is initially placed, is considered visited.
Determine whether there exists a sequence of operations where the piece moves one cell to the right exactly times, and if it exists, find one such sequence.
You are given test cases; solve each of them.
Constraints
- The sum of over all test cases is at most .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Each test case is given in the following format:
Output
Output the answers for the test cases in order, separated by newlines.
For each test case, if there is no sequence of operations satisfying the condition, output No.
If there exists a sequence of operations satisfying the condition, output it in the following format:
Here, represents the -th move, and is one of the following:
-
Lif the piece moves one cell to the left -
Rif the piece moves one cell to the right -
Uif the piece moves one cell up -
Dif the piece moves one cell down
If there are multiple sequences of operations satisfying the condition, any of them will be accepted.
3
3 4
2 1
5 10
Yes
RRDLLDRR
No
Yes
RRRRDDDLLLURRULLLDDDRRRR
Consider the first test case.
By moving from cell in order to cells , you can move one cell to the right four times and reach cell .
- Source: AtCoder ABC 474 G
相关
在下列比赛中: