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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| #include <bits/stdc++.h> using namespace std; #define FO(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout) #define fo(i,j,k) for(int i=(j),end_i=(k);i<=end_i;i++) #define ff(i,j,k) for(int i=(j),end_i=(k);i< end_i;i++) #define fd(i,j,k) for(int i=(j),end_i=(k);i>=end_i;i--) #define DEBUG(x) cout<<#x<<"="<<x<<endl #define all(x) (x).begin(),(x).end() #define cle(x) memset(x,0,sizeof(x)) #define lowbit(x) ((x)&-(x)) #define ll long long #define ull unsigned ll #define db double #define lb long db #define pb push_back #define mp make_pair #define fi first #define se second inline int read() { int x=0; char ch=getchar(); bool f=0; for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1; for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+(ch^48); return f?-x:x; } #define CASET fo(___,1,read()) const int N=2005; int n,m,max_le,max_ri,ans; struct node{ int x,y,l,r; }; queue<node> q; bool vis[N][N]; inline void update(node u) { node v; for(v=u,v.x--;;v.x--) { if(v.x<=0||vis[v.x][v.y]) break; vis[v.x][v.y]=1; q.push(v); ans++; } for(v=u,v.x++;;v.x++) { if(v.x>n||vis[v.x][v.y]) break; vis[v.x][v.y]=1; q.push(v); ans++; } } inline void Left(node u) { if(u.l>=max_le) return; u.y--; u.l++; if(u.y<=0||vis[u.x][u.y]) return; vis[u.x][u.y]=1; ans++; q.push(u); update(u); } inline void Right(node u) { if(u.r>=max_ri) return; u.y++; u.r++; if(u.y>m||vis[u.x][u.y]) return; vis[u.x][u.y]=1; ans++; q.push(u); update(u); } char s[N]; int main() { n=read(); m=read(); int nx=read(),ny=read(); max_le=read(); max_ri=read(); fo(i,1,n) { scanf("%s",s+1); fo(j,1,m) vis[i][j]=(s[j]=='*'); } if(vis[nx][ny]==1) return puts("0"); q.push((node){nx,ny,0,0}); vis[nx][ny]=1; update((node){nx,ny,0,0}); ans++; for(;!q.empty();) { node u=q.front(); q.pop(); Left(u); Right(u); } printf("%d",ans); return 0; }
|