Language: C++

#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define F first
#define S second
#define INF 1000000

using namespace std;
typedef pair<int, int> pii;

class Comp {
public:
    bool operator() (pair<pii, int> p1, pair<pii, int> p2) {
        return p1.S < p2.S;
    }
};

int r, c;
vector<vector<int>> dp;
vector<vector<bool>> g;
vector<vector<bool>> vis;

bool isSafe(int row, int col) {
    return row < r && row >= 0 && col < c && col >= 0 && g[row][col];
}

int main() {
    fastIO;
    int startX, startY, endX, endY;
    cin >> r >> c >> startX >> startY >> endX >> endY;
    startX--, startY--, endX--, endY--;

    g = vis = vector<vector<bool>>(r, vector<bool>(c, false));
    dp = vector<vector<int>>(r, vector<int>(c, 100000));

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            char temp;
            cin >> temp;
            if (temp == '.') g[i][j] = true;
        }
    }

    priority_queue<pair<int, pii>> q;
    q.push({{endX, endY}, 0});

    while (!q.empty()) {
        pair<int, pii> p = q.top();
        q.pop();
        int x = p.S.F, y = p.S.S, score = p.F;
        if (score >= dp[x][y]) continue;
        dp[x][y] = score;

        if (isSafe(x + 1, y) && dp[x + 1][y] > score) q.push({score, {x + 1, y}});
        if (isSafe(x - 1, y) && dp[x - 1][y] > score) q.push({score, {x - 1, y}});
        if (isSafe(x, y + 1) && dp[x][y + 1] > score) q.push({score, {x, y + 1}});
        if (isSafe(x, y - 1) && dp[x][y - 1] > score) q.push({score, {x, y - 1}});

        for (int i = x - 2; i <= x + 2; i++) {
            for (int j = y - 2; j <= y + 2; j++) {
                if (isSafe(i, j) && dp[i][j] > score + 1) q.push({score + 1, {i, j}});
            }
        }
    }

    if (dp[startX][startY] >= 10000) cout << -1;
    else cout << dp[startX][startY];

}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:11: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   46 |     q.push({{endX, endY}, 0});
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~
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:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; value_type = std::pair<int, std::pair<int, int> >]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; value_type = std::pair<int, std::pair<int, int> >]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, std::pair<int, int> >&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~