Rat chases its cheese time limit error

sir/mam please help me in this code

Here, you need to maintain a visited array as bool visited[1001][1001] and then use the following steps as:
sol[i][j]=1;
visited[i][j]=true;
and then before moving either downwards or rightwards, pls check if you have already visited that path or not as,
if(visited[i+1][j]==false && sol[i+1][j]==0)
{
downSucces=ratInMaze(maze,i+1,j,m,n,sol);
}
if(visited[i][j+1]==false && sol[i][j+1]==0)
{
rightSucces=ratInMaze(maze,i,j+1,m,n,sol);
}
Try to use this approach along with wht you have already used…and then try to submit…