NAJMAJ - Mission Ananta Jalil
Again my favorite hero Ananta Jalil? You’ve already heard about Jalil vai. He is a familiar figure of our film industry. He is very famous for his action romantic typo movies. Ananta Jalil is in a terrible mission. He tries to rescue his Queen Borsha. But there are too many obstacle in his paths. Dot (.) represents safe yards and hash (#) represents risky yards which contains bomb. He can move 4 ways left, right, up and down. He can only move one safe yard to another safe yard and it costs 1 energy per move. Can he rescue Borsha? If he can then he should rescue her with minimum amount of energy loss.
Input
Input starts with an integer t ≤ 50 which represents number of test cases. For each case input a pairs of integer R ≤ 100 and C ≤ 100 which represents row and column. Then input R lines containing C number of characters in each. These lines contains only ( ., #, A, B) characters where A and B represents the current positions of Ananta Jalil and Borsha respectively.
Output
For each case print the case number and then print these mentioned below:
If he rescued her then print “Yeah!:D I rescued my Queen losing only n energy.” without quotes. If he cannot then print “mission unpossible :P” without quote. For clarification see sample I/Os. (Note you must print unpossible because nothing is impossible for Ananta Jalil.)
Sample
Input: 2 5 5 .#... A.#.. ##... ...B. ..#.. 5 5 .#... A.#.. #.... ...B. ..#.. Output: Case 1: mission unpossible :P Case 2: Yeah!:D I rescued my Queen losing only 5 energy.
Authored By: Tanvir Hasan Anick
hide comments
nadstratosfer:
2018-06-06 09:32:52
As opposed to sample, actual input does not contain blanklines. |
|
Jacob Plachta:
2014-10-26 04:45:20
Moved to Tutorial just because there are already enough SPOJ problems that are identical or extremely similar. |
Added by: | Najmuzzaman |
Date: | 2014-10-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |