Language: C++

#include<bits/stdc++.h>
using namespace std;
int di[]={-1,0,1,0};
int dj[]={0,-1,0,1};
int INF=1e9;
int main(){
  int h,w;
  cin>>h>>w;
  int si,sj;
  cin>>si>>sj;
  int ti,tj;
  cin>>ti>>tj;
  si--;sj--;ti--;tj--;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];
  vector<vector<int>> dist(h,vector<int>(w,INF));
  deque<pair<int,int>> q;
  dist[si][sj]=0;
  q.push_back(si,sj);
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    int d=dist[i][j];
    q.pop_front();
    if(dist[i][j]!=d) continue;
    for(int v=0;v<4;v++){
       int ni=i+di[v],nj=j+dj[v];
      if(ni<0||ni>=h||nj<0||nj>=w) continue;
      if(s[ni][nj]=='#') continue;
      if(dist[ni][nj]<=d) continue;
      dist[ni][nj]=d;
      q.push_front(ni,nj);
    }
    for(int ei=-2;ei<=2;ei++){
      for(int ej=-2;ej<=2;ej++){
        int ni=i+ei,nj=j+ej;
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(s[ni][nj]=='#') continue;
        if(dist[ni][nj]<=d+1) continue;
        dist[ni][nj]=d+1;
        q.push_back(ni,nj);
      }
    }
  }
  int ans=dist[ti][tj];
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}

  


Compiler output:
a.cc: In function 'int main()':
a.cc:19:14: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(int&, int&)'
   19 |   q.push_back(si,sj);
      |   ~~~~~~~~~~~^~~~~~~
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:32:19: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_front(int&, int&)'
   32 |       q.push_front(ni,nj);
      |       ~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1501:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1501 |       push_front(const value_type& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1501:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_deque.h:1516:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1516 |       push_front(value_type&& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1516:7: note:   candidate expects 1 argument, 2 provided
a.cc:41:20: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(int&, int&)'
   41 |         q.push_back(ni,nj);
      |         ~~~~~~~~~~~^~~~~~~
/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