MLE Error - Can anyone help me out

#1

Can anyone tell the reason for this error
vector di={-2,-1,1,2,2,1,-1,-2};
vector dj={1,2,2,1,-1,-2,-2,-1};
bool inrange(int i, int j, int m, int n)
{
if(i>=1 && i<=m && j>=1 && j<=n)
return true;
else
return false;
}
typedef pair<int, int> iPair;
int bfs(vector<vector> &visit, int A, int B, int C, int D, int E, int F)
{
visit[C][D]=true;
queue<pair<iPair, int>> q;
q.push(make_pair(make_pair(C,D),0));
while(q.empty()==false)
{
pair<iPair,int> temp=q.front();
q.pop();
int i=temp.first.first;int j=temp.first.second;int z=temp.second;
visit[i][j]=true;
if(i==E && j==F)
{
return z;
}
for(int k=0; k<8; k++)
{
if(inrange(i+di[k], j+dj[k], A, B)==true && visit[i+di[k]][j+dj[k]]==false)
{

``````            q.push(make_pair(make_pair(i+di[k],j+dj[k]),z+1));
}
}
}
return -1;
``````

}
int Solution::knight(int A, int B, int C, int D, int E, int F)
{
vector<vector> visit(A+1,vector(B+1,false));
return bfs(visit,A,B,C,D,E,F);
}

#2

mark visited when you push the elements into the queue. This will save some memory.