Language: C++

#include<bits/stdc++.h>
using namespace std;

struct data
{
    int fr,sc;
};

int vis[1000003],clr[1001][1001],fx[4]={1,-1,0,0},fy[4]={0,0,1,-1},n,m,r=0;
vector<data>adj[1000003];
vector<string>vst;

int bfs2(int src,int dst)
{

    vis[src]=1; int x,y,z,i,j,sz,v,u,st,fn,zt,zn,ans=-1; data dt,tt;

    queue<int>qu; qu.push(src);

    while(!qu.empty())
    {

        v=qu.front(); qu.pop(); sz=adj[v].size();

        for(int lp=0;lp<sz;lp++)
        {

            dt=adj[v][lp]; x=dt.fr; y=dt.sc;

            st=max(0,x-2);  fn=min(n-1,x+2);
            zt=max(0,y-2);  zn=min(m-1,y+2);

            for(i=st;i<=fn;i++)
            {
                for(j=zt;j<=zn;j++)
                {
                    int e=clr[i][j];
                    if(e!=v && vis[e]==0)
                    {
                        vis[e]=vis[v]+1;

                        if(e==dst)
                        {
                            ans=vis[e]-1;  break;
                        }
                        else
                        {
                            qu.push(e);
                        }

                    }
                }

                if(ans!=-1)break;
            }


            if(ans!=-1)break;

        }


        if(ans!=-1)break;


    }


    return ans;


}

void bfs1(int sx,int sy)
{

    clr[sx][sy]=r; int x,y,z;

    queue<data>qdt; data dt,tt; dt.fr=sx; dt.sc=sy; qdt.push(dt); adj[r].push_back(dt);

    while(!qdt.empty())
    {

        tt=qdt.front(); qdt.pop();  int p=tt.fr; int q=tt.sc;

        for(int lp=0;lp<=3;lp++)
        {
            x=p+fx[lp]; y=q+fy[lp];

            if(x>=0 && y>=0 && x<=n-1 && y<=m-1)
            {
                if(clr[x][y]==0 && vst[x][y]=='.')
                {
                    dt.fr=x; dt.sc=y;  clr[x][y]=r;   adj[r].push_back(dt); qdt.push(dt);
                }
            }

        }


    }


}

int main()
{

    int a,b,c,d,i,j,k,g,h,res;
    char s[1003]; string str;

    scanf("%d %d",&n,&m);
    scanf("%d %d",&a,&b);
    scanf("%d %d",&c,&d);

    for(i=1;i<=n;i++)
    {
        scanf("%s",s);  str=string(s);  vst.push_back(str);
    }

    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(vst[i][j]=='.' && clr[i][j]==0){ r++; bfs1(i,j); }

        }
    }

    g=clr[a-1][b-1]; h=clr[c-1][d-1];

    //cout<<g<<" "<<h<<endl;


    if(g==h)printf("0\n");
    else
    {
        res=bfs2(g,h);

        printf("%d\n",res);

    }




    return 0;
}


Compiler output:
a.cc:10:12: error: template argument 1 is invalid
   10 | vector<data>adj[1000003];
      |            ^
a.cc:10:12: error: template argument 2 is invalid
a.cc: In function 'int bfs2(int, int)':
a.cc:16:58: error: reference to 'data' is ambiguous
   16 |     vis[src]=1; int x,y,z,i,j,sz,v,u,st,fn,zt,zn,ans=-1; data dt,tt;
      |                                                          ^~~~
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:4:8: note:                 'struct data'
    4 | struct data
      |        ^~~~
a.cc:23:43: error: request for member 'size' in 'adj[v]', which is of non-class type 'int'
   23 |         v=qu.front(); qu.pop(); sz=adj[v].size();
      |                                           ^~~~
a.cc:28:13: error: 'dt' was not declared in this scope; did you mean 'zt'?
   28 |             dt=adj[v][lp]; x=dt.fr; y=dt.sc;
      |             ^~
      |             zt
a.cc:28:22: error: invalid types 'int[int]' for array subscript
   28 |             dt=adj[v][lp]; x=dt.fr; y=dt.sc;
      |                      ^
a.cc: In function 'void bfs1(int, int)':
a.cc:79:15: error: template argument 1 is invalid
   79 |     queue<data>qdt; data dt,tt; dt.fr=sx; dt.sc=sy; qdt.push(dt); adj[r].push_back(dt);
      |               ^
a.cc:79:15: error: template argument 2 is invalid
a.cc:79:21: error: reference to 'data' is ambiguous
   79 |     queue<data>qdt; data dt,tt; dt.fr=sx; dt.sc=sy; qdt.push(dt); adj[r].push_back(dt);
      |                     ^~~~
/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:4:8: note:                 'struct data'
    4 | struct data
      |        ^~~~
a.cc:79:33: error: 'dt' was not declared in this scope; did you mean 'qdt'?
   79 |     queue<data>qdt; data dt,tt; dt.fr=sx; dt.sc=sy; qdt.push(dt); adj[r].push_back(dt);
      |                                 ^~
      |                                 qdt
a.cc:79:57: error: request for member 'push' in 'qdt', which is of non-class type 'int'
   79 |     queue<data>qdt; data dt,tt; dt.fr=sx; dt.sc=sy; qdt.push(dt); adj[r].push_back(dt);
      |                                                         ^~~~
a.cc:79:74: error: request for member 'push_back' in 'adj[r]', which is of non-class type 'int'
   79 |     queue<data>qdt; data dt,tt; dt.fr=sx; dt.sc=sy; qdt.push(dt); adj[r].push_back(dt);
      |                                                                          ^~~~~~~~~
a.cc:81:16: error: request for member 'empty' in 'qdt', which is of non-class type 'int'
   81 |     while(!qdt.empty())
      |                ^~~~~
a.cc:84:9: error: 'tt' was not declared in this scope; did you mean 'tm'?
   84 |         tt=qdt.front(); qdt.pop();  int p=tt.fr; int q=tt.sc;
      |         ^~
      |         tm
a.cc:84:16: error: request for member 'front' in 'qdt', which is of non-class type 'int'
   84 |         tt=qdt.front(); qdt.pop();  int p=tt.fr; int q=tt.sc;
      |                ^~~~~
a.cc:84:29: error: request for member 'pop' in 'qdt', which is of non-class type 'int'
   84 |         tt=qdt.front(); qdt.pop();  int p=tt.fr; int q=tt.sc;
      |                             ^~~
a.cc:94:62: error: request for member 'push_back' in 'adj[r]', which is of non-class type 'int'
   94 |                     dt.fr=x; dt.sc=y;  clr[x][y]=r;   adj[r].push_back(dt); qdt.push(dt);
      |                                                              ^~~~~~~~~
a.cc:94:81: error: request for member 'push' in 'qdt', which is of non-class type 'int'
   94 |                     dt.fr=x; dt.sc=y;  clr[x][y]=r;   adj[r].push_back(dt); qdt.push(dt);
      |                                                                                 ^~~~