Problem H
Rubberboots
Languages
da
en
Input
On the first line, the integer $n\in \{ 0,\ldots , 501\} $, specifying the number of instructions you have received. The follows a line with $n$ space-separated instructions. Each instruction is either an integer $k\in \{ 1,\ldots , 10^6\} $ meaning “walk forward $k$ tiles”, a capital “U” meaning “make a U-turn”, or either of “>” or “<” meaning “make a 90 degree turn” to the right or left, respectively.
Output
No more than $503$ space-separated instructions leading you back to start along safe tiles, such that the sum of integers is minimal. The last instruction must be the word exit.
Points
Group |
Point |
Input constraints |
1 |
15 |
Neither “>” or “<” occur |
2 |
19 |
“U” does not occur; “>” and “<” alternate |
3 |
21 |
All “walk forward” integers equal $2$ |
4 |
22 |
All “walk forward” integers are even |
5 |
23 |
No further constraints |
Sample Input 1 | Sample Output 1 |
---|---|
11 2 < 2 2 > 2 > 2 > 2 2 |
U 2 > 2 > 2 exit |
Sample Input 2 | Sample Output 2 |
---|---|
6 10 U U 10 U 20 |
exit |