question link is :- https://hack.codingblocks.com/contests/c/537/570
please tell me where i am wrong
my code is :-
#include<bits/stdc++.h>
using namespace std;
bool ratInMaze(char maze[10][10],int soln[10][10],int i,int j,int n,int m){
if(i==n&&j==m){
soln[n][m]=1;
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
cout<<soln[i][j]<<" ";
}
cout<<endl;
}
return true;
}
if(i>n||j>m){
return false;
}
if(maze[i][j]=='X'){
return false;
}
soln[i][j] = 1;
bool right = ratInMaze(maze,soln,i,j+1,n,m);
bool down = ratInMaze(maze,soln,i+1,j,n,m);
bool left = ratInMaze(maze,soln,i,j-1,n,m);
bool up = ratInMaze(maze,soln,i-1,j,n,m);
soln[i][j] = 0;
if(right||down||left||up){
return true;
}
return false;
}
int main() {
int n,m;
cin>>n>>m;
char maze[10][10];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>maze[i][j];
}
}
int soln[10][10]={0};
bool ans = ratInMaze(maze,soln,0,0,n-1,m-1);
if(ans==false){
cout<<"PATH NOT FOUND";
}
return 0;
}