|
||||||||||
The ChessTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 807 Accepted Submission(s): 185 Problem Description Mr Li likes playing chess very much. One day he made a simplified version of the game. The chess board is relatively smaller. He will first place only three kinds of chesses on his own behalf, namely the Chariot("ju"), the Horse("ma") and the Cannon("pao"). Then he placed some chesses on the opposite's behalf. There will be one and only one chess of the opposite marked as the General("shuai"). Mr Li wants to kill the General as soon as possible without killing other chesses. All chesses will move in the same way as in real chess games(The chinese chess). To make the game easier, the opposite's chesses will stand still. Input For each test case,the first line contains two integers n and m(2<=n,m<=10) indicating the size of the borad. The next n lines, containing m characters each, describe the board. 'C', 'M' and 'P' stand for the Chariot, the Horse and the Cannon on Mr Li's behalf. 'S' stands for the General of the opposite while 'D' stands for other chesses. Cells marked as '.' are empty. Process to the end of file. Output For each test case, first print a line saying "Scenario #k", where k is the number of the test case.Then,if Mr Li can kill the General, print the least number of steps needed. Otherwise print the sentence "OH!That's impossible!".Print a blank line after each test case, even after the last one. Sample Input
Sample Output
Source | ||||||||||
|