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

#define all(v) v.begin(),v.end()
#define INF INT_MAX
#define mod 1000000007
#define forgraph(n)   for(auto nebr=graph[n].begin();nebr!=graph[n].end();nebr++)
#define fori(x,n) for(int i=x;i<n;i++)
#define forj(y,m) for(int j=y;j<m;j++)
#define FASTIO std::ios::sync_with_stdio(false);
#define max_len 1000005
#define N 2010

char graph[N][N];
bool visited[N][N];
struct node{int x,y,l,r;};

int n,m;
int x_limit,y_limit;

bool isvalid(int x,int y)
{
     if(x>-1 && x < n && y>-1 && y < m)
         return  true;
     else
         return false;
}

void bfs(int r,int c)
{
    deque<node> qu;
    qu.push_back({r,c,0,0});
    
    while(!qu.empty())
    {
        node p=qu.front();
        qu.pop_front();

        int x=p.x;
        int y=p.y;
        int left=p.l;
        int right=p.r;
        
        if(visited[x][y]) continue;

        visited[x][y]=true;
       
        if(isvalid(x-1,y)&&graph[x-1][y]=='.' &&!visited[x-1][y])   qu.push_front({x-1,y,left,right});
        
        if(isvalid(x+1,y)&&graph[x+1][y]=='.' &&!visited[x+1][y])    qu.push_front({x+1,y,left,right});
        
        if(isvalid(x,y+1)&&graph[x][y+1]=='.'&&right<y_limit &&!visited[x][y+1])  qu.push_back({x,y+1,left,right+1});

        if(isvalid(x,y-1)&&graph[x][y-1]=='.'&& left<x_limit  &&!visited[x][y-1])  qu.push_back({x,y-1,left+1,right});
      
    }

}

signed main() {
    
    FASTIO
    cin>>n>>m;
    int r,c;
    cin>>r>>c;
    cin>>x_limit>>y_limit;

    fori(0,n)
    cin>>graph[i];
    int count=0;
    
    bfs(r-1,c-1);

     fori(0,n)
    forj(0,m)
    if(visited[i][j])
    count++;
    
    cout<<count<<endl;  
}

Generated URL:

Runtime Errors:

Segmentation Fault (SIGSEGV)

Output:

No Output
Report Bug