CLLEXO EDITORIAL

May be this can help.

1 Like

ok this thing would have worked if we made an matrix of constant size?

1 Like

That person says so… you can try (I’m not sure and away from my laptop).

1 Like

Thankyou for the information :ok_hand: :grin:

1 Like

Thanks for the information :blush::grin:

1 Like

https://www.codechef.com/viewsolution/35761019
please help me to find a test case for which my solution is giving wrong answer

i didn’t get this reachable thing

I am assuming that you have understood how this problem has been reduced to finding the lexicographical path from (1,1) to (N,M) in a grid. So, the thing is that you can include a point in your answer for the lexicographically smallest, only if that point can reach to the end point that is (N,M). This can also be written as checking whether the point is reachable from (N,M) or not because if (N,M) is reachable from (I,J) then (I,J) will be reachable from N,M on applying the reverse path. So, the idea is to run a single DFS from (N,M) to check for every point in O(NM) rather than doing it separately for every point which will require O(NMNM)

Can someone help me why I got TLE, my solution is optimized

https://www.codechef.com/viewsolution/43654783