经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Maze Problem

📝 题解 🔵 仅限 C++
题目描述
<p> Given a maze, find a shortest path from start to goal. </p>
输入格式
<p> Input consists serveral test cases. </p> <p> First line of the input contains number of test case T. </p> <p> For each test case the first line contains two integers N , M ( 1 &lt;= N, M &lt;= 100 ). </p> <p> Each of the following N lines contain M characters. Each character means a cell of the map. </p> <p> Here is the definition for chracter. </p> <p> &nbsp; </p> <p> Constraint: </p> <ul> <li> For a character in the map: <ul> <li> 'S' : start cell </li> <li> 'E' : goal cell </li> <li> '-' : empty cell </li> <li> '#' : obstacle cell </li> </ul> </li> <li> no two start cell exists. </li> <li> no two goal cell exists. </li> </ul>
输出格式
<p> For each test case print one line containing shortest path. If there exists no path from start to goal, print -1. </p>
样例
样例输入 1
1 5 5 S-### ----- ##--- E#--- ---##
样例输出 1
9
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用