Cyf0511 @ 2024-10-27 16:25:00
#include<bits/stdc++.h>
#define N 1005
using namespace std;
int n,m,T,x,y,d,ans,k;
bool f[N][N];
char a[N][N];
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d%d%d",&n,&m,&k,&x,&y,&d);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>a[i][j];
memset(f,false,sizeof f);
ans=0;
f[x][y]=true;
for(int i=1;i<=k;i++)
{
if(d==0)
{
if(a[x][y+1]=='.'&&y+1<=m)
f[x][++y]=true;
else
d=(d+1)%4;
continue;
}
if(d==1)
{
if(a[x+1][y]=='.'&&x+1<=n)
f[++x][y]=true;
else
d=(d+1)%4;
continue;
}
if(d==2)
{
if(a[x][y-1]=='.'&&y-1>=1)
f[x][--y]=true;
else
d=(d+1)%4;
continue;
}
if(d==3)
{
if(a[x-1][y]=='.'&&x-1>=1)
f[--x][y]=true;
else
d=(d+1)%4;
continue;
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(!f[i][j])
ans++;
printf("%d\n",ans);
}
return 0;
}
by sdjjdjdjdjd @ 2024-10-27 16:28:23
让你统计走过的,你统计的是什么?
by Cyf0511 @ 2024-10-27 16:29:26
多谢大佬