Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;



int main(){
    int h,w;
    cin >> h >> w;

    int sx,sy,gx,gy;
    cin >> sy >> sx >> gy >> gx;
    sx--;sy--;gx--;gy--;

    pair<int,int> s = make_pair(sx,sy), g = make_pair(gx,gy); 

    string sur[h];

    for(int i = 0; i < h; i++) cin >> sur[i];

    auto inout = [&](int x,int y){
        if(0 <= x && x < w && 0 <= y && y < h){
            //cout << "true" << " " << x << " " << y << endl;
            return true;
        }
        else{
            //cout << "false" << " " << x << " " << y << endl;
            return false;
        }
    };

    auto add = [&](pair<int,int> now,int dx,int dy){
        pair<int,int> ret = make_pair(now.first+dx,now.second+dy);
        return ret;
    };

    deque<pair<pair<int,int>,int>> dq;
    map<pair<int,int>,bool> seen;

    vector<vector<int>> ans(h,vector<int>(w,mod));

    int dx[4] = {0,0,1,-1}, dy[4] = {1,-1,0,0};

    dq.push_back(make_pair(s,0));
    seen[s] = true;
    ans[s.second][s.first] = 0;

    int a = 4,b = 1;

    while(!dq.empty()){
        pair<pair<int,int>,int> now = dq.front();
        dq.pop_front();
        if(now.second > ans[now.second][now.first]) continue;
        for(int i = 0; i < 4; i++){
            if(inout(now.first.first+dx[i],now.first.second+dy[i])){
                pair<int,int> nxtz = add(now.first,dx[i],dy[i]);
                if(sur[nxtz.second][nxtz.first] == '.'){
                    if(ans[nxtz.second][nxtz.first] <= now.second) continue;
                    else{
                        ans[nxtz.second][nxtz.first] = now.second;
                        seen[nxtz] = true;
                        dq.push_back(make_pair(nxtz,now.second));
                    }
                } else { 
                    for(int j = -2; j < 3; j++){
                        for(int k = -2; k < 3; k++){
                            if(j == 0 && k == 0) continue;
                            int x = now.first.first+j, y = now.first.second+k;
                            if(inout(x,y)){
                                if(sur[y][x] ==  '.' && ans[y][x] > now.second+1){
                                    
                                    ans[y][x] = now.second+1;
                                    dq.push_back(make_pair(make_pair(x,y),now.second+1));
                                    seen[make_pair(x,y)]= true;
                                } 
                            }
                        }
                    }
                }
            }
        }

    }

    int fans = ans[g.second][g.first];
    if(fans == mod) cout << -1 << endl;
    else cout << fans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:40: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::pair<int, int>')
   55 |         if(now.second > ans[now.second][now.first]) continue;
      |                                        ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~