SPIKES  Spiky Mazes
Jarmtin is interested in cultures and the history behind them. Of course this interest has a reason: as he studies the choivans’ past he discovers the hidden entrances of mazes he knows contain valuable information. However there is a catch: the mazes contain spiky traps! Jarmtin is quite the agile type, but there is a limit to everyone, thus he will only be able to avoid a number of traps. This motivates the question can he make it through the mazes?
Jarmtin is interested in cultures and the history behind them. Of course this interest has a reason: as he studies the choivans’ past he discovers the hidden entrances of mazes he knows contain valuable information. However there is a catch: the mazes contain spiky traps! Jarmtin is quite the agile type, but there is a limit to everyone, thus he will only be able to avoid a number of traps. This motivates the question can he make it through the mazes?
Input
The first line of a test case contains three integers n, m and j. n (2<=n<=40) the number of rows, m (2<=n<=40) the width of each row and j (0<=j<=20) the number of times Jarmtin can avoid spikes. Then n lines containing m characters; The character ‘x’ will be used for the place of the treasure, ‘@’ for an entrance (which is also an exit), ‘#’ for walls, ‘.’ for a safe walking tile and ‘s’ for spikes. Note that you cannot walk into walls and the maze is completely surrounded by walls outside what you can see. There is always at least one entrance/exit and always an x where the treasure is.
Output
You should output “SUCCESS” if Jarmtin can make it in and out alive, and “IMPOSSIBLE” if there is no way you can make it out alive.
Sample Input / Output
Example 1:
Input:
3 3 2
#@#
#s#
#x#
Output:
SUCCESS
Example 2:
Input:
4 4 3
####
@.s#
##.#
#xs#
Output:
IMPOSSIBLE
hide comments
JordanBelfort:
20140125 00:17:06
nice problem 

Vipul Pandey:
20140124 14:26:25
very nice problem.it is not as easy as it looks. And yes there may be more than 1 entry/exit. Last edit: 20140124 15:36:57 

RAJDEEP GUPTA:
20130812 12:55:14
What are the possible moves ?? 

mehmetin:
20130811 13:04:03
I considered only one entry/exit point and got accepted. If there can be more than one entry/exit, test data is weak. Last edit: 20130811 13:08:55 

Laurens:
20130811 09:46:27
@Kevin, it is possible that a map contains more than one entry/exit. If you can take another route to exit again after you reached the treasure, is up to your algorithm to find out. Last edit: 20130811 09:47:05 

Kevin Sebastian:
20130811 05:23:52
is there more than one way to get the treasure..i.e if path to the the treasure can be different from path to exit 

(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20130811 02:22:56
Look like this problem is easier than my Maze problem :) 
Added by:  Laurens 
Date:  20130810 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Self created problem 