The_43_Bachelor @ 2024-11-09 10:51:38
#include<bits/stdc++.h>
using namespace std;
long long t,ans=1;
int main() {
// freopen("explore.in","r",stdin);
// freopen("explore.out","w",stdout);
cin>>t;
for(int t1=1; t1<=t; t1++) {
long long n,m,k,x,y,d,ans=1;
bool bz[1010][1010];
char s[1010][1010];
cin>>n>>m>>k>>x>>y>>d;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
cin>>s[i][j];
bz[i][j]=false;
}
}
bz[x][y]=true;
for(int i=1; i<=k; i++) {
if(d==0) {
if(s[x][y+1]=='.') {
y=y+1;
if(bz[x][y]==false) {
ans++;
bz[x][y]=true;
}
} else {
d=(d+1)%4;
continue;
}
}
if(d==1) {
if(s[x+1][y]=='.') {
x=x+1;
if(bz[x][y]==false) {
ans++;
bz[x][y]=true;
}
} else {
d=(d+1)%4;
continue;
}
}
if(d==2) {
if(s[x][y-1]=='.') {
y=y-1;
if(bz[x][y]==false) {
ans++;
bz[x][y]=true;
}
} else {
d=(d+1)%4;
continue;
}
}
if(d==3) {
if(s[x-1][y]=='.') {
x=x-1;
if(bz[x][y]==false) {
ans++;
bz[x][y]=true;
}
} else {
d=(d+1)%4;
continue;
}
}
}
cout<<ans<<endl;
}
return 0;
}
by wzh11223344 @ 2024-11-09 10:53:20
你去博客看看