Problem p02579 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
#include <random>
using namespace std;
typedef unsigned long long _ulong;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end)                                                     \\
  for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \\
  for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define endk '\\n'
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = {0, -1, 1, 0, 1, -1, 1, -1}, dy[8] = {1, 0, 0, -1, -1, -1, 1, 1};

lint H, W, dp[1000][1000], sy, sx, gy, gx;
char mp[1000][1000];

struct tlint {
  lint y;
  lint x;
};

int main() {
  cin >> H >> W;
  cin >> sy >> sx;
  sy--;
  sx--;
  cin >> gy >> gx;
  gy--;
  gx--;
  REP(i, H) {
    REP(j, W) {
      cin >> mp[i][j];
      dp[i][j] = INF;
    }
  }

  deque<tlint> que;
  dp[sy][sx] = 0;
  que.push_front({sy, sx});
  while (!que.empty()) {
    tlint curr = que.front();
    que.pop_front();
    if (curr.y == gy && curr.x == gx)
      break;
    REP(k, 4) {
      lint ny = curr.y + dy[k], nx = curr.x + dx[k];
      if (ny < 0 || ny >= H || nx < 0 || nx >= W)
        continue;
      if (mp[ny][nx] == '#')
        continue;
      if (dp[ny][nx] > dp[curr.y][curr.x]) {
        dp[ny][nx] = dp[curr.y][curr.x];
        que.push_front({ny, nx});
      }
    }
    REP(i, 5) {
      REP(j, 5) {
        lint ny = curr.y - 2 + i, nx = curr.x - 2 + j;
        if (ny < 0 || ny >= H || nx < 0 || nx >= W)
          continue;
        if (mp[ny][nx] == '#')
          continue;
        if (dp[ny][nx] > dp[curr.y][curr.x] + 1) {
          dp[ny][nx] = dp[curr.y][curr.x] + 1;
          que.push_back({ny, nx});
        }
      }
    }
  }

  if (dp[gy][gx] == INF)
    cout << -1 << endk;
  else
    cout << dp[gy][gx] << endk;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18

int main() {
  ll h, w;
  cin >> h >> w;
  char s[1005][1005];
  ll sx, sy, gx, gy;
  cin >> sy >> sx >> gy >> gx;
  sx--;
  sy--;
  gx--;
  gy--;
  ll xs[4] = {1, -1, 0, 0};
  ll ys[4] = {0, 0, 1, -1};

  ll dp[1005][1005];
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      cin >> s[i][j];
      dp[i][j] = inf;
    }
  }

  queue<pair<ll, ll>> q;

  q.push({sy, sx});
  dp[sy][sx] = 0;
  // ll mn=0;
  while (!q.empty()) {

    ll cx = q.front().second;
    ll cy = q.front().first;
    if (cx == gx && cy == gy)
      break;

    q.pop();
    for (ll i = 0; i < 4; i++) {
      ll nx = cx + xs[i];
      ll ny = cy + ys[i];

      if (ny < 0 || nx < 0 || nx >= w || ny >= h)
        continue;
      if (s[ny][nx] == '#')
        continue;
      if (dp[ny][nx] > dp[cy][cx]) {
        dp[ny][nx] = dp[cy][cx];
        q.push({ny, nx});
      }
    }

    for (ll i = 0; i < 5; i++) {
      for (ll j = 0; j < 5; j++) {
        ll nx = cx - 2 + i;
        ll ny = cy - 2 + j;

        if (ny < 0 || nx < 0 || nx >= w || ny >= h)
          continue;
        if (s[ny][nx] == '#')
          continue;
        if (dp[ny][nx] > dp[cy][cx] + 1) {
          dp[ny][nx] = dp[cy][cx] + 1;
          q.push({ny, nx});
        }
      }
    }
  }

  if (dp[gy][gx] == inf)
    cout << "-1\\n";
  else
    cout << dp[gy][gx] << endl;
  return 1;
}