Language: C++

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int, int> P;


struct Node {
    int x, y, step = 0;
};
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int visited[maxn][maxn],ans[maxn][maxn];
    int dir[4][2] = { 1,0,0,1,-1,0,0,-1 };
    int H,W,Ch,Dh,Cw,Dw;
    const int maxn=1e3 + 5;
    char Maze[maxn][maxn];
    cin >> H >>W  >> Ch >> Cw >> Dh >> Dw;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            char temp;
            cin >> temp;
            Maze[i][j] = temp;
            ans[i][j] = -1;

        }
    }
    deque<Node> List;
    List.push_front((Node) {Cw, Ch, 0 });

    while (!List.empty())
    {
        Node nd = List.front(); List.pop_front();
        int x = nd.x,y=nd.y,step=nd.step;
        if (visited[y][x])continue;
        visited[y][x] = 1;
        ans[y][x] = step;
        for (int i = 0; i < 4; i++)
        {
            int xx = x + dir[i][0], yy = y + dir[i][1];
            if (xx >= 0 && xx < W && yy >= 0 && yy < H && !visited[yy][xx] && Maze[yy][xx] == '.')
            {
                List.push_front((Node) { xx, yy, temp });
            }
        }
        for (int xx = x - 2; xx <= x + 2; xx++)
        {
            for (int yy = y - 2; yy <= y + 2; yy++)
            {
                if (xx >= 0 && xx < W && yy >= 0 && yy < H && !visited[yy][xx] && Maze[yy][xx] == '.')
                {
                    List.push_back((Node) { xx, yy, step + 1 }));
                }

            }
        }
    }
    if (ans[Dh][Dw] < 0) cout << "-1";
    else cout << ans[Dh][Dw];

    
    
    

    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: 'maxn' was not declared in this scope; did you mean 'main'?
   18 |     int visited[maxn][maxn],ans[maxn][maxn];
      |                 ^~~~
      |                 main
a.cc:30:13: error: 'Maze' was not declared in this scope
   30 |             Maze[i][j] = temp;
      |             ^~~~
a.cc:31:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |             ans[i][j] = -1;
      |             ^~~
      |             abs
a.cc:42:13: error: 'visited' was not declared in this scope
   42 |         if (visited[y][x])continue;
      |             ^~~~~~~
a.cc:43:9: error: 'visited' was not declared in this scope
   43 |         visited[y][x] = 1;
      |         ^~~~~~~
a.cc:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |         ans[y][x] = step;
      |         ^~~
      |         abs
a.cc:48:79: error: 'Maze' was not declared in this scope
   48 |             if (xx >= 0 && xx < W && yy >= 0 && yy < H && !visited[yy][xx] && Maze[yy][xx] == '.')
      |                                                                               ^~~~
a.cc:50:50: error: 'temp' was not declared in this scope
   50 |                 List.push_front((Node) { xx, yy, temp });
      |                                                  ^~~~
a.cc:57:83: error: 'Maze' was not declared in this scope
   57 |                 if (xx >= 0 && xx < W && yy >= 0 && yy < H && !visited[yy][xx] && Maze[yy][xx] == '.')
      |                                                                                   ^~~~
a.cc:59:64: error: expected ';' before ')' token
   59 |                     List.push_back((Node) { xx, yy, step + 1 }));
      |                                                                ^
      |                                                                ;
a.cc:65:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   65 |     if (ans[Dh][Dw] < 0) cout << "-1";
      |         ^~~
      |         abs