头痛感冒加上某某某人的原因。。好累啊。。。现在都想睡觉了。。。
/*
zoj_1438 搜索
简单bfs,三维迷宫,注意下行列层不要混淆就好
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
using namespace std;
char map[11][11][11];
bool flag[11][11][11];
int way[6][3]={ 0,0,1,0,0,-1,1,0,0,-1,0,0,0,1,0,0,-1,0 };
struct node
{
int x,y,z,step;
node( int a=0,int b=0,int c=0,int s=0 )
{
x=a , y=b , z=c , step=s ;
}
};
int main()
{
int n,i,j,k;
node sta,end,temp,t;
string s;
bool mark;
queue <node>q;
while( cin>>s )
{
memset( flag,0,sizeof(flag) );
cin>>n;
for( i=0;i<n;i++ )
for( j=0;j<n;j++ )
for( k=0;k<n;k++ )
cin>>map[i][j][k]; //i第几层,j第几行,k第几列
cin>>sta.z>>sta.y>>sta.x; sta.step=0; //输入顺序注意
cin>>end.z>>end.y>>end.x>>s;
q.push( sta ); flag[sta.x][sta.y][sta.z]=1;
mark=0;
while( !q.empty() )
{
temp=q.front(); q.pop();
if( temp.x==end.x && temp.y==end.y && temp.z==end.z )
{
mark=1;
break;
}
for( i=0;i<6;i++ )
{
t.x=temp.x+way[i][0];
t.y=temp.y+way[i][1];
t.z=temp.z+way[i][2];
t.step=temp.step+1;
if( t.x>=0 && t.x<n && t.y>=0 && t.y<n && t.z>=0 && t.z<n
&& map[t.x][t.y][t.z]=='O' && flag[t.x][t.y][t.z]==0 )
{
flag[t.x][t.y][t.z]=1;
q.push(t);
}
}
}
if( mark ) cout<<n<<" "<<temp.step<<endl;
else cout<<"NO ROUTE\n";
while( !q.empty() ) q.pop();
}
return 0;
}