Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 1000
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> pi;

struct data {
	int r,c,d;
};

data newData(int r , int c , int d) {
	data s;
	s.r = r;
	s.c = c;
	s.d = d;
	return s;
}

bool operator<(const data& a , const data& b) {
	return a.d > b.d;
}

int n,m,ax,ay,bx,by;
int dist[maxn][maxn];
string s[maxn];
int dir[4] = {0,1,0,-1};
priority_queue<data> Q;

int main() {
	scanf("%d%d%d%d%d%d",&n,&m,&ax,&ay,&bx,&by);
	for( int i = 0 ; i < n ; i++ )
		cin >> s[i];
	memset(dist,-1,sizeof(dist));
	Q.push(newData(ax,ay,0));
	while(!Q.empty()) {
		data temp = Q.top();
		Q.pop();
		int r = temp.r;
		int c = temp.c;
		int d = temp.d;
		dist[r][c] = d;
		if(r == bx && c == by)
			break;
		for( int i = 0 ; i < 4 ; i++ ) {
			int x = r+dir[i];
			int y = c+dir[i^1];
			if(!x || x > n || !y || y > m)
				continue;
			if(dist[x][y] != -1 || s[x][y] == '#')
				continue;
			Q.push(newData(x,y,d));
		}
		for( int x = r-2 ; x <= r+2 ; x++ )
			for( int y = c-2 ; y <= c+2 ; y++ ) {
			if(x < 1 || x > n || y < 1 || y > m)
				continue;
				if(dist[x][y] != -1 || s[x][y] == '#')
					continue;
				Q.push(newData(x,y,d+1));
			}
	}
	printf("%d\n",dist[bx][by]);
	return 0;
}

Compiler output:
a.cc:16:1: error: reference to 'data' is ambiguous
   16 | data newData(int r , int c , int d) {
      | ^~~~
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:12:8: note:                 'struct data'
   12 | struct data {
      |        ^~~~
a.cc:24:22: error: reference to 'data' is ambiguous
   24 | bool operator<(const data& a , const data& b) {
      |                      ^~~~
/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:12:8: note:                 'struct data'
   12 | struct data {
      |        ^~~~
a.cc:24:38: error: reference to 'data' is ambiguous
   24 | bool operator<(const data& a , const data& b) {
      |                                      ^~~~
/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:12:8: note:                 'struct data'
   12 | struct data {
      |        ^~~~
a.cc:24:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
   24 | bool operator<(const data& a , const data& b) {
      |      ^~~~~~~~
a.cc:32:20: error: template argument 1 is invalid
   32 | priority_queue<data> Q;
      |                    ^
a.cc:32:20: error: template argument 2 is invalid
a.cc:32:20: error: template argument 3 is invalid
a.cc: In function 'int main()':
a.cc:39:11: error: request for member 'push' in 'Q', which is of non-class type 'int'
   39 |         Q.push(newData(ax,ay,0));
      |           ^~~~
a.cc:39:16: error: 'newData' was not declared in this scope
   39 |         Q.push(newData(ax,ay,0));
      |                ^~~~~~~
a.cc:40:18: error: request for member 'empty' in 'Q', which is of non-class type 'int'
   40 |         while(!Q.empty()) {
      |                  ^~~~~
a.cc:41:17: error: reference to 'data' is ambiguous
   41 |                 data temp = Q.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:12:8: note:                 'struct data'
   12 | struct data {
      |        ^~~~
a.cc:42:19: error: request for member 'pop' in 'Q', which is of non-class type 'int'
   42 |                 Q.pop();
      |                   ^~~
a.cc:43:25: error: 'temp' was not declared in this scope; did you mean 'tm'?
   43 |                 int r = temp.r;
      |                         ^~~~
      |                         tm
a.cc:56:27: error: request for member 'push' in 'Q', which is of non-class type 'int'
   56 |                         Q.push(newData(x,y,d));
      |                           ^~~~
a.cc:64:35: error: request for member 'push' in 'Q', which is of non-class type 'int'
   64 |                                 Q.push(newData(x,y,d+1));
      |                                   ^~~~