Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 1e3 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";

int m, n;
ii s, t;
char a[siz][siz];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int mx[20] = {1, -1, 1, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1};
int my[20] = {1, -1, -1, 1, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2};
int d[siz][siz];
bool done[siz][siz];

bool check(ii p) {
    return (1 <= p.fi && p.fi <= m && 1 <= p.se && p.se <= n && a[p.fi][p.se] == '.');
}

int Dijkstra() {
    priority_queue <ii, vector <iii>, greater <iii> > pq;
    memset(d, 0x3f, sizeof(d));
    d[s.fi][s.se] = 0;
    pq.push(iii(d[s.fi][s.se], s));

    while (!pq.empty()) {
        ii u = pq.top().se;
        pq.pop();

        if (done[u.fi][u.se]) {
            continue;
        }
        done[u.fi][u.se] = true;

        for (int i = 0; i < 4; i++) {
            ii v = ii(u.fi + dx[i], u.se + dy[i]);

            if (!check(v)) {
                continue;
            }

            if (d[v.fi][v.se] > d[u.fi][u.se]) {
                d[v.fi][v.se] = d[u.fi][u.se];
                pq.push(iii(d[v.fi][v.se], v));
            }
        }

        for (int i = 0; i < 20; i++) {
            ii v = ii(u.fi + mx[i], u.se + my[i]);

            if (!check(v)) {
                continue;
            }

            if (d[v.fi][v.se] > d[u.fi][u.se] + 1) {
                d[v.fi][v.se] = d[u.fi][u.se] + 1;
                pq.push(iii(d[v.fi][v.se], v));
            }
        }
    }

    if (d[t.fi][t.se] > m * n) {
        return -1;
    }
    return d[t.fi][t.se];
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    cin >> m >> n;
    cin >> s.fi >> s.se >> t.fi >> t.se;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a[i][j];
        }
    }

    cout << Dijkstra();

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Compiler output:
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, std::pair<long long int, long long int> > >, std::greater<std::pair<long long int, std::pair<long long int, long long int> > > >':
a.cc:43:55:   required from here
   43 |     priority_queue <ii, vector <iii>, greater <iii> > pq;
      |                                                       ^~
/usr/include/c++/14/bits/stl_queue.h:520:67: error: static assertion failed: value_type must be the same as the underlying container
  520 |       static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
      |                                                                   ^~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: note: 'std::integral_constant<bool, false>::value' evaluates to false