Why is my code giving wrong answer?

#include<bits/stdc++.h>
using namespace std;

bool rat(char arr[][1000], int n, int m,int i, int j, int soln[][1000]){

if(i==n-1 && j==n-1){
	soln[i][j] = 1; 
		for(int i = 0; i < n ;i++){
			for(int j = 0; j < m ; j++){
				cout<<soln[i][j]<<" ";
			}
			cout<<endl;
		}
		cout<<endl;
		return true;
	}

if(i>=n||j>=m) return false;
if(arr[i][j] == 'X') return false;
if(soln[i][j] == 1) return false;

	soln[i][j] = 1;

	bool down = rat(arr,n,m,i+1,j,soln);
	bool right = rat(arr,n,m,i,j+1,soln);

	soln[i][j] = 0; 

	if(down || right){
		return true;
	}

	return false;
}

int main() {
int n,m;
cin>>n>>m;
char arr[1000][1000];
for(int i = 0; i<n ; i++){
for(int j = 0; j<m ; j++){
cin>>arr[i][j];
}
}
int soln[1000][1000];
bool ans = rat(arr,n,m,0,0,soln);

if(ans==false){
	cout<<"-1"<<endl;
}
	return 0;

}

Please share your code using ide.codingblocks.com , so that i can debug it. If you don’t know how to share it using ide.codingblocks.com, you can ask me that too.

please let me knw how to do that??

Check now =>


Go to ide.codingblocks.com then press save while writing your code there, it will generate a special url, share that with anyone whom you want to share it with.

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.