My issue
While going through solution, I didn’t get the 2nd case of T+2 answer. How both robots will reach (N, M) simultaneously if robot1 follows the shortest path and robot2 follows the shortest path after 2 extra steps. In this case robot1 will reach first and then robot2. They are not reaching simultaneously here.
Problem Link: https://www.codechef.com/problems/ROBO2
Suppose the first robot reached at t seconds then the second robot who started 2 seconds later , will head towards the destination and the first robot will move to one empty block at t+1 second and then at t+ 2 second t hey both will reach simultaneouly
Got it.
At destination also, one blank cell adjacent to destination cell will be available which robot 1 can use to reach at t + 1 seconds after reaching destination cell at t seconds. Until then, robot 2 also would have reached some cell adjacent to destination cell in t - 1 seconds. Now both robot 1 and robot 2 are one cell adjacent to destination cell, and then, they both can reach destination cell simultaneously.
robot1 time = t + 2;
robot2 time = t;
minimum necessary time = max(t + 2, t) = t + 2;
Thankyou!
Mistake. Both robots will take t + 2 seconds as robot2 started following shortest path after 2 seconds.