在一个M×N的迷宫中,找出最短路径离开迷宫。
' S ':起点;' G ':终点;' # ':墙壁;’ . ‘:路
For example:
Input:
10 11
#S########
#.######.#
......#..#
.#.##.##.#
.#........
##.##.####
....#....#
.#######.#
....#.....
.####.###.
....#...G#
Output:
23
宽搜+计步解决。
#include<cstdio>
#include<queue>
using namespace std;
int bfs(char map[101][101],int m,int n,int i,int j,int count[]);
int main()
{
int m,n,i,j,count[10000]={};
char map[101][101];
while(scanf("%d %d",&m,&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%s",&map[i]);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
if(map[i][j]=='S&