Compute distance to the nearest gate for every empty room.
Multi-source BFS starting from all gates (value 0).
When expanding, only update cells with INF (2147483647) and set them to current + 1.
BFS from multiple sources assigns the shortest distance to the closest gate.
Compute distance to the nearest gate for every empty room.
Multi-source BFS starting from all gates (value 0).
When expanding, only update cells with INF (2147483647) and set them to current + 1.
BFS from multiple sources assigns the shortest distance to the closest gate.