1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
   |  #include <bits/stdc++.h> using namespace std; const int N = 2005; int n, m, r, c, X, Y, vis[N][N], ans; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; char s[N][N]; struct node{     int x, y, l, r; };
  void bfs(){     deque<node> Q;     Q.push_back((node){r, c, X, Y});     while(!Q.empty()){         node now =  Q.front();         Q.pop_front();         if(vis[now.x][now.y] || (now.l<0) || (now.r<0)){             continue;         }         vis[now.x][now.y] = 1; ans++;         for(int i = 0; i < 4; i++){             int xx = now.x + dx[i];             int yy = now.y + dy[i];             if(xx < 1 || xx > n || yy < 1 || yy > m || s[xx][yy] == '*' || vis[xx][yy]) continue;             if(i == 0 || i == 1) {             	Q.push_front((node){xx, yy, now.l, now.r});             	continue;             }             if(i == 2){                 Q.push_back((node){xx, yy, now.l-1, now.r} );                 continue;             }             if(i == 3) {                 Q.push_back((node){xx, yy, now.l, now.r-1} );                 continue;             }         }     }     printf("%d\n", ans); }
  int main(){     cin >> n >> m >> r >> c >> X >> Y;     for(int i = 1; i <= n; i++){         scanf("%s", s[i]+1);     }     bfs();
      return 0; }
 
 
 
  |