#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;
int gx(int a){return (a%50) + 1;}
int gy(int a){return ((a/50)%50) + 1;}
int gz(int a){return ((a/2500)%50) + 1;}
int tv(int x, int y, int z){return (x-1) + (y-1)*50 + (z-1)*2500;}
int tab[52][52][52] = {0};
int vis[52][52][52];
int main(){
int xx, yy, zz; scanf("%d %d %d", &xx, &yy, &zz);
memset(vis, -1, sizeof(vis));
for(int lx = 1;lx <= xx;lx++) for(int ly = 1;ly <= yy;ly++) tab[lx][ly][0] = tab[lx][ly][zz+1] = 1;
for(int lx = 1;lx <= xx;lx++) for(int lz = 1;lz <= zz;lz++) tab[lx][0][lz] = tab[lx][yy+1][lz] = 1;
for(int lz = 1;lz <= zz;lz++) for(int ly = 1;ly <= yy;ly++) tab[0][ly][lz] = tab[xx+1][ly][lz] = 1;
for(int lz = 1;lz <= zz;lz++)
for(int ly = 1;ly <= yy;ly++)
for(int lx = 1;lx <= xx;lx++)
scanf("%d", &tab[lx][ly][lz]);
if(tab[1][1][1]){
puts("no route");
return 0;
}
vis[1][1][1] = 0;
queue<int> que;
que.push(0);
const int dx[] = {0, 0, 0, 0, 1, -1},
dy[] = {1, -1, 0, 0, 0, 0},
dz[] = {0, 0, 1, -1, 0, 0};
while(que.size()){
int prc = que.front(); que.pop();
int px = gx(prc), py = gy(prc), pz = gz(prc);
for(int t = 0;t < 6;t++){
int nx = px + dx[t], ny = py + dy[t], nz = pz + dz[t];
if(tab[nx][ny][nz]) continue;
if(vis[nx][ny][nz]!=-1) continue;
vis[nx][ny][nz] = prc;
que.push(tv(nx, ny, nz));
}
}
if(vis[xx][yy][zz] == -1){
puts("no route");
return 0;
}
vector<int> hist;
int now = tv(xx, yy, zz);
while(now){
hist.push_back(now);
now = vis[gx(now)][gy(now)][gz(now)];
}
printf("(1,1,1)");
for(int lx = ((int)hist.size())-1;lx>=0;lx--){
int prc = hist[lx];
printf("->(%d,%d,%d)",gx(prc),gy(prc),gz(prc));
}
puts("");
return 0;
}
沒有留言:
張貼留言