Rat in a maze problem

#include
using namespace std;

bool find_path(char inp[][1005], int out[][1005], int i, int j, int n, int m){
if(i==n && j==m){
out[i][j]=1;
for(int k=0; k<n; k++){
for(int l=0; l<m; l++){
cout<<out[k][l]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}
if(i>n || j>m){
return false;
}
if(inp[i][j]==‘X’){
return false;
}
out[i][j]=1;

bool right= find_path(inp, out, i, j+1,n,m);
if(right){
	return true;
}

bool down= find_path(inp, out, i+1, j, n,m);
if(down){
	return true;
}
//backtracking
out[i][j]=0;
return false;

}

int main() {
int n,m;
cin>>n>>m;
char inp[1005][1005];

for(int i=0; i<n; i++){
	for(int j=0; j<m; j++){
	cin>>inp[i][j];
	}
}
int out[1005][1005]={0};
bool ans=find_path(inp, out,0,0, n-1, m-1);
if(!ans){
	cout<<"-1"<<endl;
}
return 0;

}

I have passed only one test case…plz help me

@rohit_2425 corrected changed 3 lines (also if not passed on first attempt submit again some tech bug)


dont forget to hit like and mark resolved if cleared :smiley:

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.