For some tile (x, y), how can we determine when, if ever, the fire will reach it?
提示 2
We can use multi-source BFS to find the earliest time the fire will reach each cell.
提示 3
Then, starting with a given t minutes of staying in the initial position, we can check if there is a safe path to the safehouse using the obtained information about the fire.
提示 4
We can use binary search to efficiently find the maximum t that allows us to reach the safehouse.