1802: Magic Tower
内存限制:128 MB
时间限制:2.000 S
评测方式:文本比较
命题人:
提交:0
解决:0
题目描述
输入
The input will consist of multiple cases. Your program should process to the end of the input file.
In the first line of each case, there are three integers N, M, and H. The hero has H Hp at the beginning of the game. 3 ≤ N, M ≤ 12. H > 0.
The next N lines describe the maze of the game, M characters each line. The characters is from the set {‘.’,’#’,’@’,’*’,’A’-‘Z’}.No other characters will appear.
- The character‘.’ represents an empty place. The hero can freely walk into these places.
- The character‘#’ represents some obstacles, such as walls, trees, etc. The hero can not walk into any obstacles.
- The character‘@’ represents the starting place of the hero. It is of course an empty place.
- The character‘*’ represents the place of the princess. If the hero manages to arrive at this place, he wins.
- The uppercase character ‘A’-‘Z’ represent the elements described before. There are totally T elements. 0 ≤ T ≤ 12. The elements are represented by distinct characters,which are the first T characters in the alphabet.
- If it is “Monster”, it is followed by an integer mi describing the hp the hero may lose if he meets with the monster.
- If it is “Herb”, it is followed by an integer hi describing the hp the hero may increase if he picks up the herb.
- If it is “Key”, it is followed by a word describing the color of the key.
- If it is “Door”, it is followed by a word describing the color of the door.
输出
The output will consists of three lines for each case.
The first line is in the format of “Case X:”. X is the number of the input case counting from 1.
The second line is an integer describing the minimum number of steps to reach the princess. The hero can only move to the adjacent four places, and can never move out of the maze. You may assume there are walls around the maze. If there is no way to reach the princess, just output “Impossible!”
The third line should be the path leading the hero to the princess. Each character of the path should be in the set of { “ ^ ” , ” < ” , ” v ” , ” > ” }, which means walking up, left, down and right. If there are many solutions, you should output in accordance with the following order: “ ^ ” , ” < ” , ” v ” , ” > ” . If the path does not exist, just output “Game Over!”
Separate cases by one blank line.
样例输入 复制
5 5 5
.....
.###.
.#...
.#.##
@#..*
5 5 5
.....
.###.
.#...
.#.##
@#.#*
5 5 5
.....
.###.
.#...
.#A#D
@#BC*
A Monster 4
B Herb 5
C Monster 10
D Monster 5
5 5 5
*#B..
A.##.
...#.
.#.#.
@#...
A Door Red
B Key Red
样例输出 复制
Case 1:
16
^^^^>>>>vv<<vv>>
Case 2:
Impossible!
Game Over!
Case 3:
20
^^^^>>>>vv<<vv^^>>vv
Case 4:
28
^^>>vv>>^^^^<<>>vvvv<<^^<^<^