O. 迷宫寻路

    Type: RemoteJudge 1000ms 128MiB

迷宫寻路

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.

题目描述

机器猫被困在一个矩形迷宫里。

迷宫可以视为一个 n×mn\times m 矩阵,每个位置要么是空地,要么是墙。机器猫只能从一个空地走到其上、下、左、右的空地。

机器猫初始时位于 (1,1)(1, 1) 的位置,问能否走到 (n,m)(n, m) 位置。

输入格式

第一行,两个正整数 n,mn,m

接下来 nn 行,输入这个迷宫。每行输入一个长为 mm 的字符串,# 表示墙,. 表示空地。

输出格式

仅一行,一个字符串。如果机器猫能走到 (n,m)(n, m),则输出 Yes;否则输出 No

3 5
.##.#
.#...
...#.
Yes

提示

样例解释

路线如下:$(1,1)\to (2,1) \to (3,1) \to (3,2)\to (3,3) \to (2, 3) \to (2, 4) \to (2, 5) \to (3, 5)$

数据规模与约定

对于 100%100\% 的数据,保证 1n,m1001 \leq n, m \leq 100,且 (1,1)(1,1)(n,m)(n, m) 均为空地。

2025CSP-J DFS【李】

Not Claimed
Status
Done
Problem
39
Open Since
2025-9-24 0:00
Deadline
2025-10-3 23:59
Extension
24 hour(s)