|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||0||0||0||0.000%|
We are all familiar with conventional mazes laid out on a 2-D grid. A 3-D maze can be constructed as follows: Consider a hollowed out cube aligned along the x, y and z axes with one corner at (0,0,0) and the opposite corner at (n − 1,n − 1,n − 1). On each face of the cube is a 2-D maze made by removing a subset of 1 × 1 × 1 cubes from the face (no edge cubes are removed). The object of the maze is to move a marker located inside the cube from an initial location of (1,1,1) to the final destination of (n − 2,n − 2,n − 2). However, attached to this marker are 6 rods, each protruding through one face of the cube. The movement of these rods is constrained by the 2-D mazes on the faces. The picture below gives an example of a 7 × 7 × 7 maze. Note that this maze is not physically realizable since some faces (e.g., the front face containing the letter “A”) have cubes that are disconnected from the edges of the face. Such mazes are allowed in this problem.
The black regions indicate open spaces where the rods can move. The figure to the right specifies the possible directions that the rods can move (Forward, Back, Left, Right, Up, Down) and also defines the labels for the six sides of the cube. In the maze above, the rods are shown in their initial position centered at (1,1,1). From here they can not move Forward, Backward, Right, Left or Down, but they can move Up (assuming there are open spaces for the two back rods to move to).
To specify a cube, a description of each face must be given. For this problem, the order and orientations of each face are given in the diagram below.
The first square represents the Forward face oriented so that the shared edge with the Up face is on top and the shared edge with the Right face is on the right, the second square represents the Right face oriented with the shared edge with the Up face on top and the shared edge with the Back face on the right, and so on. Your job is to solve such mazes in the minimum number of moves.
Each test case will start with a single line containing the value of n, where n lies between 4 and 30, inclusive. Next will come descriptions of each face in the order and orientation shown above. The description of each face will consist of n lines each containing one string of length n. The characters in the string will be either a blank or ‘X’, indicating either an empty or full square, respectively. The last test case will be followed by a line containing 0.
Output will consist of one line for each test case. Each line will contain a description of a minimum-move solution that moves the marker from cell (1,1,1) to cell (n − 2,n − 2,n − 2). Moves are either F, B, L, R, U or D. In case of a tie, choose the sequence of moves which is lexicographically first, where we consider F < B < L < R < U < D. All mazes will have solutions.
7 XXXXXXX X X X XXX X X X X XXX X X XXX X XXXXXXX XXXXXXX X X X X X X X X X X X X X X X X X X XXXXXXX XXXXXXX X X X X X X X X X X XXXXXXX XXXXXXX X X X X X X X X X X X X X X XXXXXXX XXXXXXX X XXX X X XXX X X XXX X X XXX X X X XXXXXXX XXXXXXX X X X XXX X X X X X X XXX X X X XXXXXXX 0