Robotoptimering
문제
There's a robot in an grid, where some unit squares are blocked so that the robot cannot walk on the square. Now she wants to move to another square, and have asked her owner to program her to do this. This owner happen to be you.
To transfer the programming to a robot from your computer requires a lot of energy, so you want to make the program as short as possible - this means using as few commands as possible. As everyone knows, the robot programming language looks as follows:
forwardMove the robot forward a single step in its current direction.rightRotate clockwise.leftRotate counterclockwise.for X { A1 A2 ... An} Repeat the commandsA1,A2, ...,Antimes.call XJump to the instruction with labelX, and add it to the current position in the call stack.returnJump to the last added position in the call stack, and remove it.gotoblocked XJump to the instruction with labelX, if the square in front of the robot is blocked.
A label has the syntax labelnamn:, and may only consist of small letters. A label cannot be inside a loop. The execution starts at the label called main.
입력
Input consists of 10 different grids, which you can download here: robot.zip. Each grid is formatted as follows:
The first line contains the testcase name.
The next line contains two integers and , the number of rows and columns in the grid.
Each square is one of:
.free square#blocked squareMgoal square<>^vstart square, indicating the direction of the robot (in the order left, right, up, down).
출력
It should consist of a program on the form described above, that moves the robot from its starting position to the end position.