P6391 [COCI 2007/2008 #4] KOCKE
Description
In a 2D Cartesian coordinate system, there is a robot located at the point $(0,0)$. Each time, it can move one grid cell up, down, left, or right. There are also $5$ magnets located at different positions.
Each time the robot moves, it can push the magnet in the destination cell. However, when two magnets have a face touching each other (that is, they are on adjacent coordinates), they will attract each other and form a single whole. Pushing any one of them will have the same effect on the whole group.
You need to give one movement plan for the robot such that, after moving, these $5$ magnets form a `T` shape (rotation is not allowed).
Input Format
The input consists of $5$ lines. Each line contains two integers $x, y$, describing the position of one magnet.
The testdata guarantees that no two magnets are on the same coordinate or on adjacent coordinates.
Output Format
Output one line with a string representing the magnet-moving plan. The moves are:
- `L`: move one cell to the left;
- `R`: move one cell to the right;
- `U`: move one cell up;
- `D`: move one cell down.
At most $9999$ steps.
Explanation/Hint
#### Constraints
For $100\%$ of the testdata, it is guaranteed that $-5 \le x, y \le 5$.
#### Notes
**This problem is translated from [COCI2007-2008](https://hsin.hr/coci/archive/2007_2008/) [CONTEST #4](https://hsin.hr/coci/archive/2007_2008/contest4_tasks.pdf) *T6 KOCKE*.**
**Thanks to @[一扶苏一](https://www.luogu.com.cn/user/65363) for providing the SPJ!**
Translated by ChatGPT 5