Problem list
Log in
#coci00060 · COCI 2007/2008 Contest 4

Kocke

Diamond V 1.0 s 32 MB

A robot and five cubes are placed on an infinite board composed of unit squares. The robot and the cubes occupy one square each.

The robot can be moved in each of four directions: up, down, left and right. If the square the robot would enter contains a cube, then the robot pushes it in the direction of movement.

The cubes possess curious magnetic properties. When two cubes are in neighbouring squares (squares that share a side), they join and become one object. If the robot pushes a cube that is joined with one or more other cubes, all cubes in the group move together.

Write a program that controls the robot so that it joins all cubes into a single group which (when viewed from above) forms the letter T in the upright position (it may not be rotated).

Input

The input consists of five lines. Each line contains two integers $X$ and $Y$ ($-5 \le X, Y \le 5$), the starting coordinates of one cube.

The robot is initially in square $(0, 0)$. No cubes will be located at those coordinates.

No pair of cubes will initially be at the same or neighbouring coordinates. More precisely, no cubes will initially share a side (they may share corners).

Output

Output a string of characters representing the robot's moves on a single line. Each character must be one of U (up), D (down), L (left), R (right).

The sequence must be at most $9999$ characters long.

Example 1

Input
0 1
-1 0
1 0
0 -1
0 -3
Output
DRRUUULLDD

Example 2

Input
-2 0
-1 -1
0 -2
1 0
0 1
Output
URRDLLURUULDDLLLDR
Source
COCI 2007/2008 Contest 4
Appears in
Not part of a ladder, contest or set yet.
Accepted 1 Submissions 2 Acceptance 100% Solvers 1

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code