Maze Traversal
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
There is an grid maze (indicating rows and columns), where some cells are passable and others are not. If 1 represents a passable cell and 0 represents an impassable cell, read the data from the input, along with the starting point and ending point (both described by two values, representing the row number and column number of the point respectively). Your task is to program to find all viable paths under the following rules:
-
No repeated points are allowed in the path.
-
Movement is restricted to the four directions: up, down, left, right.
If there are no viable paths, output the corresponding information (use to indicate no path).
Priority order for movement: up, left, right, down. The data is guaranteed to be randomly generated.
Input Format
The first line contains two integers (). Next are lines of columns of data consisting of 1s and 0s. The last two lines are the starting point and ending point.
Output Format
All viable paths. Each point is described in the form (x, y)
. Except for the starting point, all other points are connected using ->
to denote the direction.
If there are no viable paths, output .
Sample Input
5 6
1 0 0 1 0 1
1 1 1 1 1 1
0 0 1 1 1 0
1 1 1 1 1 0
1 1 1 0 1 1
1 1
5 6
Sample Output
(1,1)->(2,1)->(2,2)->(2,3)->(2,4)->(2,5)->(3,5)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(2,4)->(2,5)->(3,5)->(3,4)->(4,4)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(2,4)->(2,5)->(3,5)->(3,4)->(3,3)->(4,3)->(4,4)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(2,4)->(3,4)->(3,5)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(2,4)->(3,4)->(4,4)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(2,4)->(3,4)->(3,3)->(4,3)->(4,4)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(3,3)->(3,4)->(3,5)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(3,3)->(3,4)->(2,4)->(2,5)->(3,5)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(3,3)->(3,4)->(4,4)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(3,3)->(4,3)->(4,4)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(3,3)->(4,3)->(4,4)->(3,4)->(3,5)->(4,5)->(5,5)->(5,6)
(1,1)->(2,1)->(2,2)->(2,3)->(3,3)->(4,3)->(4,4)->(3,4)->(2,4)->(2,5)->(3,5)->(4,5)->(5,5)->(5,6)
Note
The data is guaranteed to be randomly generated. In fact, if and every cell is 1, there are paths.
2025XCPC集训队&&算法培训 — 综合训练(一)
- 状态
- 已结束
- 规则
- ACM/ICPC
- 题目
- 5
- 开始于
- 2025-8-22 19:00
- 结束于
- 2025-8-22 22:00
- 持续时间
- 3 小时
- 主持人
- 参赛人数
- 21