F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

The Chess

Time 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
5 5 ..DSD ...D. C.... P.D.. ...M. 7 7 .DDSDD. ..DDD.. ...D... .....P. .C..... ...M... .......
 

Sample Output
Scenario #1 2 Scenario #2 OH!That's impossible!
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 17:12:16, Gzip enabled