_Sunday_ @ 2024-11-05 17:25:00
#include<bits/stdc++.h>
using namespace std;
int t;
int n,m,k;
int x,y,d;
bool a[1005][1005];
bool flag[1005][1005];
int xx[4]={0,1,0,-1},yy[4]={1,0,-1,0};
int main(){
//freopen("explore.in","r",stdin);
//freopen("explore.out","w",stdout);
cin>>t;
while(t--){
cin>>n>>m>>k;
cin>>x>>y>>d;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char c;cin>>c;
if(c=='x') a[i][j]=false;
else a[i][j]=true;
flag[i][j]=false;
}
}
flag[x][y]=true;
while(k--){
if(a[x+xx[d]][y+yy[d]]){
x+=xx[d];y+=yy[d];
}
else{
d=(d+1)%4;
}flag[x][y]=true;
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(flag[i][j]){
ans++;
}
}
}
cout<<ans<<'\n';
}
return 0;
}
#7 #10 WA
感谢神犇!!!
by q_hacker_p @ 2024-11-05 20:12:28
接下来,机器人判断它下一步的位置是否在地图内\
所以,判一下边界。\
你这不RE,CCF数据真烂。
by q_hacker_p @ 2024-11-05 20:14:17
@F001
by _Sunday_ @ 2024-11-06 16:09:42
@q_hacker_p Thank you!
by _Sunday_ @ 2024-11-06 16:10:32
@q_hacker_p 确实挺烂的