走迷宫最小步数
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
一个迷宫由R行C列格子组成,有的格子里有障碍物,不能走;有的格子是空地,可以走。
给定一个迷宫,求从左上角走到右下角最少需要走多少步(数据保证一定能走到)。只能在水平方向或垂直方向走,不能斜着走。
Format
Input
第一行是两个整数,R和C,代表迷宫的长和宽。( 1<= R,C <= 40) 接下来是R行,每行C个字符,代表整个迷宫。 空地格子用‘.’表示,有障碍物的格子用‘#’表示。 迷宫左上角和右下角都是‘.’。
Output
输出从左上角走到右下角至少要经过多少步(即至少要经过多少个空地格子)。计算步数要包括起点和终点。
Samples
5 5
..###
#....
#.#.#
#.#.#
#.#..
9
Limitation
1s, 1024KiB for each test case.
3.1
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 10
- Start at
- 2025-2-28 17:15
- End at
- 2025-3-21 13:15
- Duration
- 500 hour(s)
- Host
- Partic.
- 4