For this Problem
The solution is written in O(n*m)
But How it is possible if there is recursion calls inside the nested solution.
Solution in tutorial is:
https://codeforces.net/blog/entry/116108 (Problem E)
Please someone help me understand the time complexity?Shouldn't it be O(n*m*n*m).I know we are not checking same grid twice.
Please someone help me.