Runtime error in bfs


#1

always getting runtime error.
code:
int Solution::solve(vector<vector > &A) {
queue<pair<int,int>> q;

map<pair<int,int>,bool> visited;
int len=0;
int best=0;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,1,-1,-1,1};
for(int i=0;i<A.size();i++){
    for(int j=0;j<A[0].size();j++){
        
        if(!visited[{i,j}] and A[i][j]){
            q.push({i,j});
            visited[{i,j}]=true;
            len=0;
         while(!q.empty()){
            pair<int,int> node=q.front();
             q.pop();
            int key=0;
            len++;
            for(int k=0;k<8;k++){
            int m=node.first+dx[k];
            int n=node.second+dy[k];
                if(!visited[{m,n}] and m>=0 and n>=0 and m<A[0].size() 
                     and n<A.size() and A[m][n]){
                        q.push({m,n});
                         visited[{m,n}]=true;
                        //len++;
                 }
            }
    
         }
         if(len>best){
             best=len;
         }
        }
        
    }
}
return best;

}