← 返回 meta 的题目列表AI Coding Maze: Bomb Triggers Wall Destruction Within Radius 2 (State BFS)
类型:online_judge
Add bomb cells B to the maze. The first time you step onto B, it explodes and turns all walls # within Manhattan distance <= 2 from that bomb into passable empty cells . (or an equivalent 'destroyed' state). You then continue walking on the updated map.
Given S, E, #, ., and B, return the shortest steps from S to E (4-directional). Return -1 if unreachable.
You must extend visited with state about whether the bomb has been triggered / which walls are destroyed so BFS is correct.
Suggested constraints for interview version: R,C <= 50, number of bombs <= 1 (multiple bombs would require a richer state representation).
Example
Input
3 5
S#..E
##B##
.....
Output
8