← 返回 meta 的题目列表Maze Pathfinding
类型:online_judge
Problem: Maze Pathfinding
You are given a maze as an m x n grid grid, where:
0 means an empty cell
1 means a wall
You are also given a start coordinate start = (sr, sc) and a target coordinate target = (tr, tc).
Determine whether there exists a path from start to target. From a cell, you may move one step up/down/left/right to an adjacent empty cell (0). You cannot go out of bounds or pass through walls.
Input (stdin)
m n
<next m lines: n integers (0/1) separated by spaces>
sr sc
tr tc
Output (stdout)
Print one line:
true if a path exists
false otherwise
Constraints
1 <= m, n <= 200
Example
Input:
3 3
0 0 1
0 0 0
1 0 0
0 0
2 2
Output:
true
Example
Input
1 1
0
0 0
0 0
Output
true