This question is completely changed according to zoj1940 a bit of input and output ... The code doesn't change much.
#include <iostream> #include <queue> #include <string> #include <memory.h> using namespace std;
Char maze[11][11][11]; const int pmove[4][2]={{0,1},{0,-1},{-1,0},{1,0}};//moves int z;//How many groups of int n;//how many rows int m;//how many columns int sx,sy,ex,ey,sz,ez; int Aste
Roids ();
struct Node {friend bool operator < (node A,node b) {return a.step>b.step;
} int x,y,z,step;
};
int main () {int i,j;
String str;
while (CIN>>STR) {cin>>n;
M=z=n;
Memset (Maze, ' X ', sizeof (maze));
if (z==0&&n==0&&m==0) break;
for (int. icase=0;icase<z;icase++) for (i=0;i<n;i++) for (j=0;j<m;j++) cin>>maze[icase][i][j];
cin>>sx>>sy>>sz>>ex>>ey>>ez>>str;
int tmp;
Tmp=asteroids ();
if (tmp!=-1) cout<<z<< ' <<tmp<<endl;
else cout<< "NO ROUTE" <<endl;
} return 0;
} int asteroids () {priority_queue<node> que;
Node now,temp;
int V;
NOW.X=SX; Now.y=sy;
Now.z=sz;
Now.step=0;
Que.push (now);
maze[sz][sy][sx]= ' X ';
while (!que.empty ()) {temp=que.top ();
Que.pop ();
if (Temp.x==ex&&temp.y==ey&&temp.z==ez) return temp.step; for (int i=0;i<z;i++)//Crossing {if (temp.z-1>=0) if (maze[temp.z-1][temp.y][temp.x]!= ' x ') {now=temp
;
now.z--;
now.step++;
Que.push (now);
maze[temp.z][temp.y][temp.x]= ' x ';
maze[temp.z-1][temp.y][temp.x]= ' x ';
} if (Temp.z+1<z) if (maze[temp.z+1][temp.y][temp.x]!= ' x ') {now=temp;
now.z++;
now.step++;
Que.push (now);
maze[temp.z+1][temp.y][temp.x]= ' x '; }} for (v=0;v<4;v++)//Normal move {for (int i=0;i<z;i++)//Cross {if (temp.z-1>=0) if (maze[temp.z-1][
temp.y][temp.x]== '. ')
{now=temp;
now.z--;
now.step++;
Que.push (now);
maze[temp.z][temp.y][temp.x]= ' x ';
maze[temp.z-1][temp.y][temp.x]= ' x '; } if (Temp.z+1<z) if (maze[temp.z+1][temp.y][temp.x]== '. ')
{now=temp;
now.z++;
now.step++;
Que.push (now);
maze[temp.z+1][temp.y][temp.x]= ' x ';
}} Now.x=temp.x+pmove[v][0];
NOW.Y=TEMP.Y+PMOVE[V][1];
Now.z=temp.z;
now.step=temp.step+1;
if (Now.x==ex&&now.y==ey&&temp.z==ez) return now.step; if (now.x<0| | now.y<0| | now.x>m| |
Now.y>n) continue;
if (maze[temp.z][now.y][now.x]!= ' x ') {Que.push (now);
maze[temp.z][now.y][now.x]= ' x ';
}}} return-1; }