Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i) // マクロ
using namespace std;                          // stdの省略
using pii = pair<int, int>;                   // pairの略記
using ll = long long;                         // long longの略記

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main(void)
{

    int h, w, si, sj, ti, tj;
    cin >> h >> w >> si >> sj >> ti >> tj;
    --si;
    --sj;
    --ti;
    --tj; // ０スタートなのでデクリメント

    vector<string> s(h);
    rep(i, h) cin >> s[i]; // repマクロの利用

    const int INF = 1e9; // あり得ない数字
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<P> q;
    dist[si][sj] = 0;
    q.emplace_back(si, sj);
    while (!q.empty())
    {
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        if (dist[i][j] != d) continue;
        rep(v, 4)
        {
            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.emplace_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.emplace_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:25:11: error: 'P' was not declared in this scope
   25 |     deque<P> q;
      |           ^
a.cc:25:12: error: template argument 1 is invalid
   25 |     deque<P> q;
      |            ^
a.cc:25:12: error: template argument 2 is invalid
a.cc:27:7: error: request for member 'emplace_back' in 'q', which is of non-class type 'int'
   27 |     q.emplace_back(si, sj);
      |       ^~~~~~~~~~~~
a.cc:28:15: error: request for member 'empty' in 'q', which is of non-class type 'int'
   28 |     while (!q.empty())
      |               ^~~~~
a.cc:30:19: error: request for member 'front' in 'q', which is of non-class type 'int'
   30 |         int i = q.front().first;
      |                   ^~~~~
a.cc:31:19: error: request for member 'front' in 'q', which is of non-class type 'int'
   31 |         int j = q.front().second;
      |                   ^~~~~
a.cc:32:11: error: request for member 'pop_front' in 'q', which is of non-class type 'int'
   32 |         q.pop_front();
      |           ^~~~~~~~~
a.cc:33:27: error: 'd' was not declared in this scope
   33 |         if (dist[i][j] != d) continue;
      |                           ^
a.cc:39:33: error: 'd' was not declared in this scope
   39 |             if (dist[ni][nj] <= d) continue;
      |                                 ^
a.cc:40:28: error: 'd' was not declared in this scope
   40 |             dist[ni][nj] = d;
      |                            ^
a.cc:41:15: error: request for member 'emplace_front' in 'q', which is of non-class type 'int'
   41 |             q.emplace_front(ni,nj);
      |               ^~~~~~~~~~~~~
a.cc:48:37: error: 'd' was not declared in this scope
   48 |                 if (dist[ni][nj] <= d+1) continue;
      |                                     ^
a.cc:49:32: error: 'd' was not declared in this scope
   49 |                 dist[ni][nj] = d+1;
      |                                ^
a.cc:50:19: error: request for member 'emplace_back' in 'q', which is of non-class type 'int'
   50 |                 q.emplace_back(ni,nj);
      |                   ^~~~~~~~~~~~