Hide

Problem H
Rubberboots

Languages da en
/problems/gulegummistoevler/file/statement/en/img-0001.png
Sample 1.
You are participating in a silly game show on prime time Danish TV. Wearing a pair of yellow rubberboots you have been led blindfolded through a labyrinth, which you now want to leave along the shortest path. The labyrinth has no walls but consists of square tiles; you can safely walk on these tiles, but stepping off them means immediate defeat. You have been led to your current position along safe tiles, and have perfect memory.

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

Please log in to submit a solution to this problem

Log in