http://www.codechef.com/BTFR2013/problems/NITA07

How to solve this??

Bfs can be used to solve it.

1 Like

I didnâ€™t solve this one yet, but it seems as simple shortest path problem, so simply use one of the well known algorithm f.e.:

2 Likes

thanks!!!

1 Like

thanks!!!

This is a very known problem called as Rat in a Maze.

You can use BFS or Backtracking to solve this problem.

@betlista i think you do not need to use Dijkstra algorithm for this problem.

3 Likes

y dijkstra??

1 Like

this function can solve the question recursive and easy

int minCost(int cost[][C],int m, int n)

{

if (n < 0 || m < 0)

return INT_MAX;

else if (m == 0 && n == 0)

return cost[m][n];

else

return cost[m][n] + min( minCost(cost,m-1, n-1),

minCost(cost,m-1, n),

minCost(cost,m, n-1) );

}

5 Likes