Statement
Watson has built a robot that moves on a board. Holmes and Watson make a bet: arrange mirrors and walls so that the robot takes as long as possible to reach its finish cell.
The robot starts at the start cell, facing its specified initial direction. It repeatedly attempts to move one cell in its current direction. Its action depends on the cell ahead.
- If the cell is empty, the robot moves into it. The start and finish cells are also treated as empty.
- If the cell contains a mirror, the robot first determines the reflected direction using the mirror's current orientation. It then enters the mirror cell, flips the mirror, and faces the direction determined before the flip.
- If the cell is a wall, the robot stays in its current cell and reverses its direction by degrees.
- If the cell is outside the board, the robot leaves the board and can never reach the finish.
A mirror is either / or \. Flipping a mirror changes it to the other type. Reflection follows this table.
Mirror | Moving right | Moving down | Moving left | Moving up |
|---|---|---|---|---|
| Up | Left | Down | Right |
| Down | Right | Up | Left |
The incoming directions in the table are the directions the robot faces immediately before entering the mirror cell. A mirror flips only when the robot enters its cell. Reversing direction because of a wall while standing on a mirror does not flip that mirror.
Each move into an adjacent cell takes second. Direction changes take no time. The robot stops immediately upon reaching the finish.
Holmes has built a board that takes seconds. Help Watson build a board that beats Holmes. A valid board that falls short of this target can still earn partial credit.
Input
The input consists of the single integer , as follows.
This value does not affect the board requirements and may be ignored. Submit a program that prints a board.
Output
Print lines, each containing characters without spaces. The characters have the following meanings.
U,D,L,R: the start cell, initially facing up, down, left, or right, respectively.F: the finish cell..: an empty cell.#: a wall./,\: a mirror.
There must be exactly one start character in the entire board and exactly one finish character. If there are multiple solutions, print any of them.
Scoring
A board is valid only if the robot reaches the finish without leaving the board, using at most moves. Incorrect formatting, an infinite loop, or failure to reach the finish within this movement limit earns points. Reversing direction at a wall does not count as a move.
For a valid board, let be the number of moves before reaching the finish. Its score is
A board with earns points and is accepted. Merely completing moves does not earn credit: the robot must actually reach the finish.
Constraints
- The input integer is always .
- The board has rows and columns.
- Every cell contains one of
U,D,L,R,F,.,#,/, and\. - There is exactly one start and exactly one finish.
- A valid board reaches the finish after moves.
Subtasks
Samples
The robot moves two cells to the right and enters the mirror. It then faces down, but the wall below makes it turn around without moving. One upward move reaches the finish. The total is seconds, earning points. This example is valid but does not earn full credit.