又是一个样例过了,但WA的题目,但又找不出问题...
代码:
#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y,l,r;
};
node off[4]={{0,1},{0,-1},{1,0},{-1,0}};
int n,m,r,c,k1,k2,sum;
char a[2001][2001];
int main(){
cin>>n>>m>>r>>c>>k1>>k2;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
queue<node>q;
sum=1;
a[r][c]='+';
q.push((node){r,c,0,0});
while(!q.empty()){
for(int i=0;i<4;i++){
node x=q.front();
x.x=q.front().x+off[i].x;
x.y=q.front().y+off[i].y;
if(i==0) x.r++;
else if(i==1) x.l++;
if(x.x>=1&&x.x<=n&&x.y>=1&&x.y<=m&&a[x.x][x.y]=='.'&&x.l<=k1&&x.r<=k2){
q.push((node){x.x,x.y,x.l,x.r});
a[x.x][x.y]='+';
sum++;
}
}
q.pop();
}
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++){
// cout<<a[i][j]<<" ";
// }
// cout<<endl;
// }
cout<<sum;
return 0;
}