SIR/MAM,'
TODAY I WAS SOLVING THIS QUESTION,,
HERE IS MY SUBMISSION.. >> http://codeforces.net/contest/199/submission/13427391 <<
I GOT WRONG ANSWER IN 84th TEST CASE FOR THIS PROBLEM >> http://codeforces.net/contest/199/problem/D <<
PLS HELP..THANKS IN ADVANCE...
THANK YOU..
What do you want?
You can see the test and you can read the tutorial of the problem here:link
In this problem you want the shortest way out, dfs does not give you the shortest path. you should use dijkstra or bfs.