The fastest way that the rumour will travel is when the roumor starts in the middle of the matrix.
Since it travels only horizontally or vertically, if it starts from the middle then it will take m/2 + n/2
days to reach a corner in the worst case.
Just try this printf("%d\n",m/2+n/2);
it should work.
NOTE: Add 1 if you have to include a day for the starting house.
2
solved c program to print min number of days required to spread rumour in matrix [closed]