← 返回 meta 的题目列表Shortest Path in Matrix
类型:online_judge
meta
Given an NxM matrix consisting of empty squares, gates (G), and walls (W), you need to fill each empty square with the shortest path length to the nearest gate. Movements are allowed up, down, left, and right.
Example
Input
['G', 'W', ' ', ' ', 'G'], [' ', 'W', ' ', ' ', ' '], [' ', ' ', ' ', 'W', ' '], ['W', 'G', ' ', ' ', ' ']