lxr00000 @ 2024-10-26 20:06:37
#include<bits/stdc++.h>
using namespace std;
char ch[1005][1005],x,y,d,n,m,x0,yy0,d0,T,k;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main()
{
cin>>T;
while(T--)
{
int ans=0;
cin>>n>>m>>k;
cin>>x0>>yy0>>d0;
x=x0;
y=yy0;
d=d0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>ch[i][j];
}
}
for(int i=1;i<=k;i++)
{
if(ch[x+dx[d]][y+dy[d]]=='x')
{
d++;
if(d==4)d=0;
continue;
}
x+=dx[d];
y+=dy[d];
ans++;
}
cout<<ans+1<<endl;
}
}
by xianjunyong @ 2024-10-26 20:15:18
@lxr00000 输出应为走过的位置的数量,并不是路程