100 atcoder#ABC051C. [ABC051C] Back and Forth
[ABC051C] Back and Forth
Score : points
Problem Statement
Dolphin resides in two-dimensional Cartesian plane, with the positive -axis pointing right and the positive -axis pointing up. Currently, he is located at the point . In each second, he can move up, down, left or right by a distance of . Here, both the - and -coordinates before and after each movement must be integers. He will first visit the point where and , then go back to the point , then visit the point again, and lastly go back to the point . Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points and . Under this condition, find a shortest path for him.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print a string that represents a shortest path for Dolphin. The -th character in should correspond to his -th movement. The directions of the movements should be indicated by the following characters:
U
: UpD
: DownL
: LeftR
: Right
If there exist multiple shortest paths under the condition, print any of them.
0 0 1 2
UURDDLLUUURRDRDDDLLU
One possible shortest path is:
- Going from to for the first time: → → →
- Going from to for the first time: → → →
- Going from to for the second time: → → → → → → →
- Going from to for the second time: → → → → → → →
-2 -2 1 1
UURRURRDDDLLDLLULUUURRURRDDDLLDL