Language: C++

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

struct data {
  int x, y, c;
  data(int _x, int _y, int _c) : x(_x), y(_y), c(_c) {}
  bool operator < (const data& a) const {
    return c > a.c;
  }
};

int main() {
  int h, w;
  int ch, cw;
  int dh, dw;

  cin >> h >> w;
  cin >> ch >> cw;
  cin >> dh >> dw;

  ch--; cw--;
  dh--; dw--;

  vector<string> t(h);
  vector<vector<int>> v(h, vector<int>(w, -1));
  rep(i, h) cin >> t[i];

  priority_queue<data> que;

  que.push(data(cw, ch, 0));
  while(!que.empty()) {
    data cur = que.top();
    que.pop();

    int x = cur.x;
    int y = cur.y;
    int c = cur.c;

    // cout << x << ' ' << y << ' ' << c << endl;
    if(v[y][x] != -1) continue;
    v[y][x] = c;

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

    rep(i, 28) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      int nc = c + dc[i];

      if(nx < 0 || nx >= w) continue;
      if(ny < 0 || ny >= h) continue;
      if(t[ny][nx] != '.') continue;
      if(v[ny][nx] != -1) continue;

      // cout << "-> " << nx << ' ' << ny << ' ' << nc << endl;

      que.push(data(nx, ny, nc));
    }
  }

  // rep(y, h) {
  //   rep(x, w) {
  //     cout << v[y][x] << ' ';
  //   }
  //   cout << endl;
  // }

  cout << v[dh][dw] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:22: error: template argument 1 is invalid
   35 |   priority_queue<data> que;
      |                      ^
a.cc:35:22: error: template argument 2 is invalid
a.cc:35:22: error: template argument 3 is invalid
a.cc:37:7: error: request for member 'push' in 'que', which is of non-class type 'int'
   37 |   que.push(data(cw, ch, 0));
      |       ^~~~
a.cc:37:12: error: reference to 'data' is ambiguous
   37 |   que.push(data(cw, ch, 0));
      |            ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:8: note:                 'struct data'
   11 | struct data {
      |        ^~~~
a.cc:38:14: error: request for member 'empty' in 'que', which is of non-class type 'int'
   38 |   while(!que.empty()) {
      |              ^~~~~
a.cc:39:5: error: reference to 'data' is ambiguous
   39 |     data cur = que.top();
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:8: note:                 'struct data'
   11 | struct data {
      |        ^~~~
a.cc:40:9: error: request for member 'pop' in 'que', which is of non-class type 'int'
   40 |     que.pop();
      |         ^~~
a.cc:42:13: error: 'cur' was not declared in this scope
   42 |     int x = cur.x;
      |             ^~~
a.cc:66:11: error: request for member 'push' in 'que', which is of non-class type 'int'
   66 |       que.push(data(nx, ny, nc));
      |           ^~~~
a.cc:66:16: error: reference to 'data' is ambiguous
   66 |       que.push(data(nx, ny, nc));
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:8: note:                 'struct data'
   11 | struct data {
      |        ^~~~