rt,在本地编译过不鸟,蛋不汁道是什么原因,求dalao指教
#include<bits/stdc++.h>
using namespace std;
char mp[1001][1001];
int n,m,k,step,d[1000001][4];
int bfs(int,int,int);
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
memset(d,0,sizeof(d));
step=0;
cin>>n>>m>>k;
int x,y,d;
cin>>x>>y>>d;
for(int j=1;j<=n;j++)
{
for(int o=1;o<=m;o++)
{
char ch;
cin>>ch;
mp[j][o]=ch;
}
}
cout<<bfs(x,y,d)<<endl;
}
return 0;
}
int bfs(int x,int y,int d)
{
d[1][0]=x;
d[1][1]=y;
d[1][2]=0;
d[1][3]=d;
int head=0,tail=1;
while(head<tail)
{
head++;
for(int i=1;i<=k;i++)
{
int xx,yy;
if(d[head][3]==0)
{
xx=d[head][0];
yy=d[head][1]+1;
}
else if(d[head][3]==1)
{
xx=d[head][0]-1;
yy=d[head][1];
}
else if(d[head][3]==2)
{
xx=d[head][0];
yy=d[head][1]-1;
}
else if(d[head][3]==3)
{
xx=d[head][0]+1;
yy=d[head][1];
}
if(xx>=1 and xx<=n and yy>=1 and yy<=m and mp[xx][yy]=='.')
{
tail++;
d[tail][0]=xx;
d[tail][1]=yy;
d[tail][2]=d[head][2]+1;
d[tail][3]=d[head][3];
mp[xx][yy]='#';
}
else
{
d[tail][3]=(d[head][3]+1)%4;
}
}
}
return d[tail][2];
}