I can’t able to find the solution for the problem

About the problem statement , the spread can be to atmost one cell adjacent to the current cell in a day.

So, lets take a cell (x,y). We can think in this way that maximum time would be taken to reach the corners of the grid. So calculate the moves it will take to reach each corner of the grid considering that we can move only to adjacent horizontal or vertical cell.

The maximum of this 4 values will be the answer for the question.

The 4 values would be

x+c-1-y = distance of given current cell from top right corner

r-1-x+c-1-y = distance of given current cell from bottom right corner

x+y = distance of given current cell from top left corner

r-1-x+y = distance of given current cell from bottom left corner

Thanks a lot rishav

Rishav iam not understanding the distance formuales

I got it no problem