キーエンスプログラミングコンテスト2021-Nov. (AtCoder Beginner Contest 227)
H
Eat Them All
AtCoder
⌀ 3229
原题
← G→
翻译中…

Problem Statement

翻译中…

We have a grid with $3$ horizontal rows and $3$ vertical columns. Let $(i, j)$ denote the square at the $i$-th row from the top and $j$-th column from the left. $(i, j)$ contains $A_{i,j}$ cans of cat food.

翻译中…

Snuke is now on $(1,1)$. He will repeat the following action.

翻译中…
  • Consume one can on the square he is on, and move up, down, left, or right to an adjacent square.
翻译中…

When there is no more can on the square he is on, he will end this process.

翻译中…

Is it possible that all of the conditions below are satisfied at the end of the process? If it is possible, show one sequence of actions that make it happen.

翻译中…
  • Snuke is at $(1,1)$.
  • There is no more can on every square.
翻译中…

Constraints

翻译中…
  • $1 \leq A_{i,j} \leq 100$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

A_{1,1} A_{1,2} A_{1,3}
A_{2,1} A_{2,2} A_{2,3}
A_{3,1} A_{3,2} A_{3,3}

翻译中…

Output

翻译中…

If it is impossible that the conditions are satisfied, print NO.

翻译中…

If it is possible, print a string $S$ consisting of L, R, U, D. The $i$-th character of $S$ should represent the $i$-th action of Snuke, where L, R, U, D means moving one square left, right, up, down, respectively.

翻译中…

样例

Input #1
1 1 1
1 1 1
1 2 1
Output #1
DDRUDRUULL
Note that Snuke must be back on $(1, 1)$ in the end. There are also other correct outputs, such as `RRDDLUDLUU`.
Input #2
2 4 2
2 1 1
1 1 2
Output #2
NO
It is impossible to achieve the objective, so print `NO`.
Input #3
2 2 3
2 1 2
1 3 2
Output #3
DUDDRUDRLRUULRDULL
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。