Yeah, I made sure of that. But, it didnt strike me that the memoization could be done on [r][c][State].Observer wrote:Make sure that your code do not do the calculations more than once.

Hmm, but if I do that, for this case:mf wrote:It seems correct to me.
But you could make it simpler - set all edge capacities to infinity, except for those which connect to ~ cell.
Code: Select all
3 5 2
##.**
.~*~.
.....
mf wrote:If you make and post some inputs, I can show the output of my accepted program for them.
Code: Select all
3 3 1
*.*
@#@
*.*
Ans: 1
1 12 1
*#*#*#*##***
Ans: 5
2 12 1
*~*~*~*~#***
..@.@@@@.@@@
Ans: 1
2 12 2
*~*~*~*##***
..@@@@@@.@@@
Ans: 4