#P2033. Chessboard Dance
Chessboard Dance
Description
Dancing on a chessboard is an interesting thing. You are given a chessboard with some pieces on it, along with your initial position and facing direction. After performing a sequence of operations, output the final state of the board.
There are four operations, described as follows:
| Operation | Description |
|---|---|
move n |
is a non-negative integer, meaning you move forward steps in your current direction. If you are about to move off the board, stop. If there is a piece in front of you, push it forward by one square. |
turn left |
Turn left by degrees. |
turn right |
Turn right by degrees. |
turn back |
Turn around. |
Input Format
The first lines, each with characters, give the board state. . means the square is empty; letters indicate pieces, and different letters indicate different pieces. Your position is represented by one of ^, <, >, v, which indicate your facing direction up, left, right, or down, respectively.
Then there are several lines, one per operation, ending with #. The number of operations does not exceed .
Output Format
Output lines, each with characters, representing the board and your state after the sequence of operations. The representation is the same as in the input.
......bA
.....^..
........
........
........
........
........
........
move 2
turn right
move 1
#
......>b
........
........
........
........
........
........
........
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号