Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 33;
- struct T {
- int x, y, z;
- };
- char a[6][N][N];
- int vst[N][N][N];
- char dc[7] = "FBLRUD";
- int dx[6] = {1, -1, 0, 0, 0, 0};
- int dy[6] = {0, 0, -1, 1, 0, 0};
- int dz[6] = {0, 0, 0, 0, -1, 1};
- char ch[N][N][N];
- T prv[N][N][N];
- int main() {
- int n;
- for(int qq = 1; ; qq++) {
- scanf("%d", &n);
- if(n == 0) break;
- fgets(a[0][0], N, stdin);
- for(int d = 0; d < 6; d++) {
- for(int i(0); i < n; i++) {
- fgets(a[d][i], N, stdin);
- //scanf("%s", a[d][i]);
- cout << a[d][i] << endl;
- }
- }
- for(int i(0); i < n; i++) {
- for(int j(0); j < n; j++) {
- if(a[2][i][n - j - 1] == '#') a[0][i][j] = '#';
- if(a[3][i][n - j - 1] == '#') a[1][i][j] = '#';
- if(a[5][n - i - 1][j] == '#') a[4][i][j] = '#';
- }
- }
- int F = 0, R = 1, U = 4;
- vector<T> q;
- q.push_back({n - 2, n - 2, n - 2});
- for(int i(0); i < n; i++) for(int j(0); j < n; j++) for(int k(0); k < n; k++) {
- vst[i][j][k] = 0;
- }
- vst[n - 2][n - 2][n - 2] = true;
- for(int op(0); op < (int)q.size(); op++) {
- int x = q[op].x, y = q[op].y, z = q[op].z;
- for(int d(0); d < 6; d++) {
- int X = x + dx[d], Y = y + dy[d], Z = z + dz[d];
- if( a[F][n - Z - 1][n - Y - 1] == ' '
- && a[R][n - Z - 1][X] == ' '
- && a[U][n - X - 1][n - Y - 1] == ' ') {
- if(vst[X][Y][Z] == false) {
- vst[X][Y][Z] = 1;
- q.push_back({X, Y, Z});
- prv[X][Y][Z] = q[op];
- ch[X][Y][Z] = dc[d];
- }
- }
- }
- }
- string ans;
- int x = 1, y = 1, z = 1;
- while(!(x == n - 2 && y == n - 2 && z == n - 2)) {
- ans = ch[x][y][z] + ans;
- auto t = prv[x][y][z];
- x = t.x, y = t.y, z = t.z;
- }
- cout << ans << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement