#include
using namespace std;
bool ratInMaze(char maze[1001][1001],int soln[][1001],int i,int j,int m,int n)
{
if(i==m && j==n)
{
soln[m][n]=1;
for(int i=0;i<=m;i++)
{
for(int j=0;j<=n;j++)
{
cout<<soln[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}
if(i>m || j>n)
{
return false;
}
if(maze[i][j]==‘X’)
{
return false;
}
soln[i][j]=1;
bool right=ratInMaze(maze,soln,i,j+1,m,n);
bool down=ratInMaze(maze,soln,i+1,j,m,n);
soln[i][j]=0;
if(right || down)
{
return true;
}
return false;
}
int main() {
char maze[1001][1001]={
“0X00”,
“000X”,
“00X0”,
“X000”,
“XX00”,
};
int soln[1001][1001]={0};
int m,n;
cin>>m>>n;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>maze[i][j];
}
}
bool ans=ratInMaze(maze,soln,0,0,m-1,n-1);
if(ans==false)
{
cout<<"-1"<<endl;
}
return 0;
}
MY CODE NOT GIVE ANY OUTPUT