Dz8897 @ 2024-11-05 21:57:53
//GZ-J00235
#include<bits/stdc++.h>
using namespace std;
int mp[10005][10005],mc[10005][10005];
int n=0,m=0,k=0,x=0,y=0,z=0,d=0,t=0,sum=0;
char ch;
int csh(){
for(int j=0;j<=n+10;j++)
for(int q=0;q<=m+10;q++){
mp[j][q]=0;mc[j][q]=0;
}
}
int yd(){
//mp[x][y]=2;
if(d==0){
if(mp[x][y+1]==1&&x>=1&&x<=n&&y>=1&&y<=m){y++;mc[x][y]=2;}
else d=(d+1)%4;
}
else if(d==1){
if(mp[x+1][y]==1&&x>=1&&x<=n&&y>=1&&y<=m) {x++;mc[x][y]=2;}
else d=(d+1)%4;
}
else if(d==2){//N
if(mp[x][y-1]==1&&x>=1&&x<=n&&y>=1&&y<=m) {y--;mc[x][y]=2;}
else d=(d+1)%4;
}
else if(d==3){
if(mp[x-1][y]==1&&x>=1&&x<=n&&y>=1&&y<=m) {x--;mc[x][y]=2;}
else d=(d+1)%4;
}
/*
if(d==0){
if(mp[x][y+1]==2&&x>=1&&x<=n&&y>=1&&y<=m) {y++;mp[x][y]=2;}
else d=(d+1)%4;
}
else if(d==1){
if(mp[x+1][y]==2&&x>=1&&x<=n&&y>=1&&y<=m) {x++;mp[x][y]=2;}
else d=(d+1)%4;
}
else if(d==2){
if(mp[x][y-1]==2&&x>=1&&x<=n&&y>=1&&y<=m) {y--;mp[x][y]=2;}
else d=(d+1)%4;
}
else if(d==3){
if(mp[x-1][y]==2&&x>=1&&x<=n&&y>=1&&y<=m) {x--;mp[x][y]=2;}
else d=(d+1)%4;
}*/
//cout<<"F"<<x<<" "<<y<<" "<<d<<endl;
mc[x][y]=2;
return 0;
}
int main(){
freopen("explore.in","r",stdin);
freopen("explore.out","w",stdout);
cin>>t;
for(int i=1;i<=t;i++){
n=0,m=0,k=0,x=0,y=0,z=0,d=0,sum=0;
cin>>n>>m>>k;
cin>>x>>y>>d;
csh();
mc[x][y]=2;
for(int j=1;j<=n;j++){
for(int q=1;q<=m;q++){
cin>>ch;
if(ch=='x') mp[j][q]=-1;
if(ch=='.') mp[j][q]=1;
}
}
for(int o=1;o<=k;o++){
yd();
}
for(int j=1;j<=n;j++){
for(int q=1;q<=m;q++){
if(mc[j][q]==2) sum++;
}
}
cout<<sum<<endl;
}
return 0;
}
/*
2
1 5 4
1 1 2
....x
5 5 20
1 1 0
.....
.xxx.
.x.x.
..xx.
x....
*/
by huangchengyu @ 2024-11-06 20:11:07
@fyc201908 其实开一个dx,dy数组控一下方向就行了
by huangchengyu @ 2024-11-06 20:12:59
@Dz8897 dx[5]={ };dy[5]={ } 用for(i=0;i<4;i++) x1=x+dx[i],y1=y+dy[i];