niuniudundun @ 2024-12-04 20:12:45
#include<iostream>
using namespace std;
const int maxn=1e3+1;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int t;
int main(){
cin>>t;
while(t--){
int n,m,k,x,y,d;
char a[maxn][maxn];
int vis[maxn][maxn],ans=0;
cin>>n>>m>>k>>x>>y>>d;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
vis[i][j]=0;
}
}
for(int i=1;i<=k;i++){
int x_=dx[d]+x,y_=dy[d]+y;
if(x_<=n&&y_<=n&&x_>=1&&y_>=1&&a[x_][y_]=='.'){
x=x_;
y=y_;
}else{
d=(d+1)%4;
}
vis[x][y]=1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
ans+=vis[i][j];
}
}
cout<<ans<<endl;
}
return 0;
}
by ny_Dacong @ 2024-12-04 20:39:56
@niuniudundun 可以通过编译。请详细描述问题。
by niuniudundun @ 2024-12-04 20:41:08
@niuniudundun
查出来了,bool
打成 int
。
by niuniudundun @ 2024-12-04 20:42:51
@ny_Dacong