ffs와 bfs가 미로를 걷다

데이터
10 10               //      
#S######.#
......#..#
 .#.##.##.#
.#........
##.##.####
 ....#....#
.#######.#
 ....#.....
 .####.###.
 ....#...G#
 0 1              //  
 9 8             //  

출력
 22

ffs 코드:
      #include 
        #define maxn 10001
        #define INF 100001
        int n,m;
        char maze[maxn][maxn];
        int d[maxn][maxn];
        int sx,sy,gx,gy;
        int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
        int dfs(int x,int y)
        {
            if(x==gx&&y==gy)return d[x][y];                 //          
            for(int i=0;i<4;i++)
            {
                int nx=x+dx[i],ny=y+dy[i];
                if(nx>=0&&nx=0&&ny

bfs 코드:

  #include 
#include 
#include 
#define maxn 10001
#define INF 1000000
using namespace std;
typedef pairP;
char maze[maxn][maxn];
int sx,sy;
int gx,gy;
int n,m;
int d[maxn][maxn];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int bfs()
{
    queue

s; for(int i=0;i=0&&nx=0&&ny

좋은 웹페이지 즐겨찾기