Language: C++

#include <bits/stdc++.h>
//#define DBG

using namespace std;
using ll = long long;
int H, W;
int Ch, Cw, Dh, Dw;
char b[1000][1000];
ll memo[1000][1000];
vector<ll> A;

struct Corr {
    ll y;
    ll x;
    ll warpcnt;
    Corr(ll in_y, ll in_x){
        warpcnt = 0;
        y = in_y;
        x = in_x;
    }
    Corr(ll in_y, ll in_x, ll in_warpcnt){
        warpcnt = in_warpcnt;
        y = in_y;
        x = in_x;
    }
};

void printboard(){
        for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << memo[i][j] << ',' << flush;
        }
        cout << endl;
    }

}

ll minwarp = LLONG_MAX;

int main(){
    cin >> H >> W;
    cin.ignore();
    cin >> Ch >> Cw;
    --Ch;
    --Cw;
    cin.ignore();
    cin >> Dh >> Dw;
    --Dh;
    --Dw;
    cin.ignore();
 
    for(int i = 0; i < 1000; i++){
        for(int j = 0; j < 1000; j++){
            memo[i][j] = LLONG_MAX;
        }
    }
 
    for(int i = 0; i < H; i++){
        string s;
        cin >> s;
        for(int j = 0; j < W; j++){
            b[i][j] = s[j];
        }
        cin.ignore();
    }
 
    queue<Corr> q;
    q.push(Corr(Ch, Cw));
    while(!q.empty()){
        Corr now = q.front();
        q.pop();
        // マスにスコアつけ
        if(memo[now.y][now.x] <= now.warpcnt && memo[now.y][now.x] != LLONG_MAX) continue; // コスト大or訪問済みなら省略
        memo[now.y][now.x] = now.warpcnt;
        if(now.y == Dh && now.x == Dw) continue; // 目的地なら終了
        // -Y
        if(now.y > 0){
            if(b[now.y - 1][now.x] == '.' && (memo[now.y - 1][now.x] > now.warpcnt)) q.push(Corr(now.y - 1, now.x, now.warpcnt));
        }
        // -X
        if(now.x > 0){
            if(b[now.y][now.x - 1] == '.' && memo[now.y][now.x - 1] > now.warpcnt) q.push(Corr(now.y, now.x - 1, now.warpcnt));
        }
        // +Y
        if(now.y < H - 1){
            if(b[now.y + 1][now.x] == '.' && memo[now.y + 1][now.x] > now.warpcnt) q.push(Corr(now.y + 1, now.x, now.warpcnt));
        }
        // +X
        if(now.x < W - 1){
            if(b[now.y][now.x + 1] == '.' && memo[now.y][now.x + 1] > now.warpcnt) q.push(Corr(now.y, now.x + 1, now.warpcnt));
        }
 
        // ワープあり
        ll low_X = (now.x - 2 < 0) ? 0 : now.x - 2;
        ll up_X = (now.x + 2 > W - 1) ? W - 1 : now.x + 2;
        ll low_Y = (now.y - 2 < 0) ? 0 : now.y - 2;
        ll up_Y = (now.y + 2 > H - 1) ? H - 1 : now.y + 2;
        for(ll i = low_Y; i <= up_Y; i++){
            if(i < 0) continue;
            if(i > H - 1) continue;
            if(b[i][low_X] == '.' && memo[i][low_X] > now.warpcnt + 1) q.push(Corr(i, low_X, now.warpcnt + 1));
            if(b[i][up_X] == '.' && memo[i][up_X] > now.warpcnt + 1) q.push(Corr(i, up_X, now.warpcnt + 1));
        }
        for(ll i = low_X; i <= up_X; i++){
            if(i < 0) continue;
            if(i > W - 1) continue;
            if(b[low_Y][i] == '.' && memo[low_Y][i] > now.warpcnt + 1) q.push(Corr(low_Y, i, now.warpcnt + 1));
            if(b[up_Y][i] == '.' && memo[up_Y][i] > now.warpcnt + 1) q.push(Corr(up_Y, i, now.warpcnt + 1));
        }
        if(low_Y <= Dh && Dh <= up_Y && low_X <= Dw && Dw <= up_X){
            if(b[low_Y][i] == '.' && memo[Dh][Dw] > now.warpcnt + 1) q.push(Corr(Dh, Dw, now.warpcnt + 1));
        }
    }
 
    if(memo[Dh][Dw] == LLONG_MAX){
        cout << -1 << endl;
    } else {
        cout << memo[Dh][Dw] << endl;
    }
 
#ifdef DBG
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << memo[i][j] << ',' << flush;
        }
        cout << endl;
    }
#endif
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:111:25: error: 'i' was not declared in this scope
  111 |             if(b[low_Y][i] == '.' && memo[Dh][Dw] > now.warpcnt + 1) q.push(Corr(Dh, Dw, now.warpcnt + 1));
      |                         ^