Language: C++

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 1e3 + 5 ;
char c[N][N] ;
int mn[N][N] , h,w, X,Y,A,B;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int Dx[] = {-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2} ;
int Dy[] = {2,1,0,-1,-2,2,1,0,-1,-2,2,1,0,-1,-2,2,1,0,-1,-2,2,1,0,-1,-2} ;

void solve(int test) {

	cin >> h >> w ;
	cin >> A >> B ;
	cin >> X >> Y ;

	rep(i,1,h+1) rep(j,1,w+1) cin >> c[i][j] , mn[i][j] = (int)1e7 ; 

	mn[A][B] = 0 ; 
	par[A][B] = {-1,-1} ; 
	
	queue<pii> q ; q.push({A,B}) ;
	vis[A][B] = 1 ;

	while(not q.empty()) {
		int x = q.front().ff; int y = q.front().ss; q.pop() ;

		rep(i,0,4) {
			int nx = x + dx[i] , ny = y + dy[i] ;
			if(nx > h or nx < 1 or ny > w or ny < 1 ) continue ;
			// if(vis[nx][ny]) continue ;
			if(c[nx][ny] == '#') continue; 
			if(mn[nx][ny]>mn[x][y]) {
			
				mn[nx][ny] = mn[x][y]; 
				q.push({nx,ny}); 
			}
		}

		// if(par[x][y].ff != -1 ) {
			// x = par[x][y].ff , y = par[x][y].ss; 
			rep(i,0,25) {
				int nx = x + Dx[i] , ny = y + Dy[i] ;
				if(nx > h or nx < 1 or ny > w or ny < 1 ) continue ;
				// if(vis[nx][ny]) continue ;
				if(c[nx][ny] == '#') continue; 
				if(mn[nx][ny] > 1 + mn[x][y]) {
					
					mn[nx][ny] = 1 + mn[x][y] ;
					q.push({nx,ny});
				}
			}
		// }
	}

	// rep(i,1,h+1) { rep(j,1,w+1) cout << mn[i][j] << " " ; cout << nl ;}

	if(mn[X][Y] == INF) cout << -1 << nl ;
	else cout << mn[X][Y] ;
}
 
int32_t main() {
 
    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Compiler output:
a.cc: In function 'void solve(int)':
a.cc:63:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   63 |         par[A][B] = {-1,-1} ;
      |         ^~~
      |         __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:5:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:66:9: error: 'vis' was not declared in this scope; did you mean 'vii'?
   66 |         vis[A][B] = 1 ;
      |         ^~~
      |         vii