Language: C++

#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
const int INF = 1000000;

void warp_b(), bfs_a();

vector<vector<char>> maze;
vector<vector<int>> data;
queue<p> que_a, que_b;
int h,w,ch,cw,dh,dw;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0 -1};

void bfs_a(){
    while(que_a.size() > 0){
        p r = que_a.front(); que_a.pop();
        for(int i = 0; i < 4; i++){
            int nx = r.first + dx[i], ny = r.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w 
                    && maze[nx][ny] != '#' && data[nx][ny] == INF){
                data[nx][ny] = data[r.first][r.second];
                que_a.push(p(nx,ny));
                que_b.push(p(nx,ny));
            }
        }
    }
}

void warp_b(){
    while(que_b.size() > 0){
        p r = que_b.front(); que_b.pop();
        for(int x = -2; x <= 2; x++){
            for(int y = -2; y <= 2; y++){
                int nx = r.first + x, ny = r.second + y;
                if(0 <= nx && nx < h && 0 <= ny && ny < w 
                        && maze[nx][ny] != '#' && data[nx][ny] == INF){
                    data[nx][ny] = data[r.first][r.second] + 1;
                    que_a.push(p(nx, ny));
                }
            }
        }
    }
}

int main(){
    cin >> h >> w >> ch >> cw >> dh >> dw;
    vector<char> tmp(w);
    vector<int> tmp2(w, INF);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> tmp[j];
        }
        maze.push_back(tmp);
        data.push_back(tmp2);
    }
    que_a.push(p(ch - 1, cw - 1));
    que_b.push(p(ch - 1, cw - 1));
    data[ch - 1][cw - 1] = 0;

    while(que_a.size() > 0){
        bfs_a();
        warp_b();
    }
    if(data[dh - 1][dw - 1] == INF) puts("-1");
    else cout << data[dh - 1][dw - 1] << endl; 
}

Compiler output:
a.cc: In function 'void bfs_a()':
a.cc:20:47: error: reference to 'data' is ambiguous
   20 |                     && maze[nx][ny] != '#' && data[nx][ny] == INF){
      |                                               ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc:21:17: error: reference to 'data' is ambiguous
   21 |                 data[nx][ny] = data[r.first][r.second];
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc:21:32: error: reference to 'data' is ambiguous
   21 |                 data[nx][ny] = data[r.first][r.second];
      |                                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc: In function 'void warp_b()':
a.cc:36:51: error: reference to 'data' is ambiguous
   36 |                         && maze[nx][ny] != '#' && data[nx][ny] == INF){
      |                                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc:37:21: error: reference to 'data' is ambiguous
   37 |                     data[nx][ny] = data[r.first][r.second] + 1;
      |                     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc:37:36: error: reference to 'data' is ambiguous
   37 |                     data[nx][ny] = data[r.first][r.second] + 1;
      |                                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc: In function 'int main()':
a.cc:54:9: error: reference to 'data' is ambiguous
   54 |         data.push_back(tmp2);
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc:58:5: error: reference to 'data' is ambiguous
   58 |     data[ch - 1][cw - 1] = 0;
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:9:21: note:                 'std::vector<std::vector<int> > data'
    9 | vector<vector<int>> data;
      |                     ^~~~
a.cc:64:8: error: reference to 'data' is ambiguous
   64 |     if(data[dh - 1][dw - 1] == INF) puts("-1");
      |        ^~~~