I don't know why I am failing 3rd test case In Rat in a maze problem

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

using namespace std;
bool maze(char q[][1001],int sol[][1001],int i,int j,int m,int n)
{
if (i==m && j==n)
{
sol[i][j]=1;
for (int s=0;s<=m;s++)
{
for (int d=0;d<=n;d++)
{
cout<<sol[s][d]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}
else
{
if (i>m || j>n)
{
return false;
}
if (q[i][j]==‘X’)
{
return false;
}
sol[i][j]=1;
if (maze(q,sol,i,j+1,m,n)|| maze(q,sol,i+1,j,m,n))
{
sol[i][j]=0;
return true;
}
sol[i][j]=0;
return false;
}
}
int main()
{
int a,b;
cin>>a>>b;
char q[1001][1001];
for (int i=0;i<a;i++)
{
for (int m=0;m<b;m++)
{
cin>>q[i][m];
}
}
int sol[1001][1001]={0};
maze(q,sol,0,0,a-1,b-1);
return 0;
}

hello @goyalyash1962

if solution doesnt exist then in that case u need to print -1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.