Language: C++

#include <bits/stdc++.h>
char ch[2006][2006];
int s[2006][2006];
int x,y,x1,y1;
int h,w;
int falg=0;
void find1(int n,int m)
{
    ch[n][m]='1';
    if(n-1>=0&&ch[n-1][m]=='.')
        find1(n-1,m);
    if(n+1<h&&ch[n+1][m]=='.')
        find1(n+1,m);
    if(m-1>=0&&ch[n][m-1]=='.')
        find1(n,m-1);
    if(m+1<w&&ch[n][m+1]=='.')
        find1(n,m+1);
}
int find2(int n,int m)
{
    if(ch[n][m]!='1')
        return 0;
        s[n][m]=1;
    if(n-2>=0&&m-2>=0)
        if(ch[n-2][m-2]=='.')
            {ch[n-2][m-2]='1'; falg=1;}
    if(n-2>=0&&m-1>=0)
        if(ch[n-2][m-1]=='.')
            {ch[n-2][m-1]='1'; falg=1;}
    if(n-2>=0)
        if(ch[n-2][m]=='.')
            {ch[n-2][m]='1'; falg=1;}
    if(n-2>=0&&m+1<w)
        if(ch[n-2][m+1]=='.')
            {ch[n-2][m+1]='1'; falg=1;}
    if(n-2>=0&&m+2<w)
        if(ch[n-2][m+2]=='.')
            {ch[n-2][m+2]='1'; falg=1;}

    if(n-1>=0&&m-2>=0)
        if(ch[n-1][m-2]=='.')
            {ch[n-1][m-2]='1'; falg=1;}
    if(n-1>=0&&m-1>=0)
        if(ch[n-1][m-1]=='.')
            {ch[n-1][m-1]='1'; falg=1;}
    if(n-1>=0)
        if(ch[n-1][m]=='.')
            {ch[n-1][m]='1'; falg=1;}
    if(n-1>=0&&m+1<w)
        if(ch[n-1][m+1]=='.')
            {ch[n-1][m+1]='1'; falg=1;}
    if(n-1>=0&&m+2<w)
        if(ch[n-1][m+2]=='.')
            {ch[n-1][m+2]='1'; falg=1;}

    if(m-2>=0)
        if(ch[n][m-2]=='.')
            {ch[n][m-2]='1'; falg=1;}
    if(m-1>=0)
        if(ch[n][m-1]=='.')
            {ch[n][m-1]='1'; falg=1;}
    if(m+1<w)
        if(ch[n][m+1]=='.')
            {ch[n][m+1]='1'; falg=1;}
    if(m+2<w)
        if(ch[n][m+2]=='.')
            {ch[n][m+2]='1'; falg=1;}

    if(n+1<h&&m-2>=0)
        if(ch[n+1][m-2]=='.')
            {ch[n+1][m-2]='1'; falg=1;}
    if(n+1<h&&m-1>=0)
        if(ch[n+1][m-1]=='.')
            {ch[n+1][m-1]='1'; falg=1;}
    if(n+1<h)
        if(ch[n+1][m]=='.')
            {ch[n+1][m]='1'; falg=1;}
    if(n+1<0&&m+1<w)
        if(ch[n+1][m+1]=='.')
            {ch[n+1][m+1]='1'; falg=1;}
    if(n+1<h&&m+2<w)
        if(ch[n+1][m+2]=='.')
            {ch[n+1][m+2]='1'; falg=1;}

    if(n+2<h&&m-2>=0)
        if(ch[n+2][m-2]=='.')
            {ch[n+2][m-2]='1'; falg=1;}
    if(n+2<h&&m-1>=0)
        if(ch[n+2][m-1]=='.')
            {ch[n+2][m-1]='1'; falg=1;}
    if(n+2<h)
        if(ch[n+2][m]=='.')
            {ch[n+2][m]='1'; falg=1;}
    if(n+2<0&&m+1<w)
        if(ch[n+2][m+1]=='.')
            {ch[n+2][m+1]='1'; falg=1;}
    if(n+2<h&&m+2<w)
        if(ch[n+2][m+2]=='.')
            {ch[n+2][m+2]='1'; falg=1;}

}
int main()
{
//    int h,w;
    scanf("%d%d",&h,&w);
    int i;
    scanf("%d%d%d%d",&x,&y,&x1,&y1);
    for(i=0;i<h;i++)
    {
        scanf("%s",ch[i]);
    }
    find1(x-1,y-1);
    int sum=0;
    while(1)
    {
        falg=1;
        if(ch[x1-1][y1-1]=='1')
           break;
        int j;
        falg=0;
        for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
                if(ch[i][j]=='1')
                find2(i,j);
            }
        }
        if(falg==0)
        {
            printf("-1\n");
            break;
        }
        sum++;
    }
    if(falg==1)
        printf("%d\n",sum);
    return 0;
}


Compiler output:
a.cc:4:12: error: 'int y1' redeclared as different kind of entity
    4 | int x,y,x1,y1;
      |            ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:117:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  117 |         if(ch[x1-1][y1-1]=='1')
      |                     ~~^~
a.cc:117:20: error: invalid types 'char [2006][double (*)(double) noexcept]' for array subscript
  117 |         if(ch[x1-1][y1-1]=='1')
      |                    ^
a.cc: In function 'int find2(int, int)':
a.cc:101:1: warning: control reaches end of non-void function [-Wreturn-type]
  101 | }
      | ^