Language: C++

#include <bits/stdc++.h>

#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

//const vector<pii> dir{{1,0},{-1,0},{0,1},{0,-1}};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<string> a(n);
    int sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    sx--,sy--,ex--,ey--;
    for(auto& it:a) cin>>it;
    deque<pair<int,int>> q;
    const int N=1e9;
    vector<vector<int>> dis(n,vector<int>(m,N));
    dis[sx][sy]=0;
    q.emplace_back(sx,sy);
    int dir[] = { 1,0,-1,0,1 };
    while(!q.empty()){
        int x,y;
        tie(x,y)=q.front();
        q.pop_front();
        for(int i=0;i<4;i++){
            int nx=x+dir[i],ny=y+dir[i+1];
            if(unsigned(nx)<n&&unsigned(ny)<m&&a[nx][ny]=='.'){
                if(dis[x][y]<dis[nx][ny]){
                    dis[nx][ny]=dis[x][y];
                    q.pb(nx,ny);
                }
            }
        }
        for(int dx=-2;dx<=2;dx++){
            for(int dy=-2;dy<=2;dy++){
                int nx=x+dx,ny=y+dy;
                if(unsigned(nx)<n&&unsigned(ny)<m&&a[nx][ny]=='.'){
                    if(dis[x][y]+1<dis[nx][ny]){
                        dis[nx][ny]=dis[x][y]+1;
                        q.pb(nx,ny);
                    }
                }
            }
        }
    }
    cout<<(dis[ex][ey]==N?-1:dis[ex][ey]);
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:40:25: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(int&, int&)'
   40 |                     q.pb(nx,ny);
      |                     ~~~~^~~~~~~
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:139,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_deque.h:1538:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1538 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1538:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_deque.h:1553:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1553 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1553:7: note:   candidate expects 1 argument, 2 provided
a.cc:50:29: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(int&, int&)'
   50 |                         q.pb(nx,ny);
      |                         ~~~~^~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1538:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1538 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1538:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_deque.h:1553:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1553 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1553:7: note:   candidate expects 1 argument, 2 provided