Robotoptimering | 프로그래밍의 벗 PivotOJ
PivotOJ

Robotoptimering

시간 제한: 1000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — onlinekvalBOJ 21290

문제

There's a robot in an N×MN \times M 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:

  • forward Move the robot forward a single step in its current direction.
  • right Rotate 90deg90\deg clockwise.
  • left Rotate 90deg90\deg counterclockwise.
  • for X { A1 A2 ... An } Repeat the commands A1, A2, ..., An XX times.
  • call X Jump to the instruction with label X, and add it to the current position in the call stack.
  • return Jump to the last added position in the call stack, and remove it.
  • gotoblocked X Jump to the instruction with label X, 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 1R10001 \le R \le 1000 and 1C10001 \le C \le 1000, the number of rows and columns in the grid.

Each square is one of:

  • . free square
  • # blocked square
  • M goal square
  • <>^v start 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.

이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.