lidongheng66666 @ 2024-10-26 16:35:02
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,ans,t,m,k,x,y,d;
ll f[10005][10005];
char s[10005][10005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--) {
ans=1;
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];
}
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
f[i][j]=0;
}
}
f[x][y]=1;
for(int i=1; i<=k; i++) {
if(d==0) {
if(s[x][y+1]=='.') {
if(f[x][y+1]==0) {
ans++;
f[x][y+1]=1;
}
y=y+1;
} else {
d=(d+1)%4;
}
} else if(d==1) {
if(s[x+1][y]=='.') {
if(f[x+1][y]==0) {
ans++;
f[x+1][y]=1;
}
x=x+1;
} else {
d=(d+1)%4;
}
} else if(d==2) {
if(s[x][y-1]=='.') {
if(f[x][y-1]==0) {
ans++;
f[x][y-1]=1;
}
y=y-1;
} else {
d=(d+1)%4;
}
} else {
if(s[x-1][y]=='.') {
if(f[x-1][y]==0) {
ans++;
}
f[x-1][y]=1;
x=x-1;
} else {
d=(d+1)%4;
}
}
}
cout<<ans<<endl;
}
return 0;
}
by lyxqqq1 @ 2024-10-26 16:54:45
测一下 1 4 4 17 1 1 0 .... .... .... ....
by lyxqqq1 @ 2024-10-26 16:56:40
结果应是16 但你输出的是12
by nowornever0625 @ 2024-10-26 17:37:52
@lyxqqq1 为什么应该是16啊?不应该就是12吗?外面一圈12个位置走一遍。
by lyxqqq1 @ 2024-10-28 17:38:35
我犯傻了