Woburn Challenge 2016-17 Round 3 - Senior Division
Among other things, the Pokémon series of video games is known for having interesting 2D puzzles for the player to solve. The latest installment, Pokémon Navy Green, is no exception!
As one of the game's level designers, you've been given the responsibility of turning different rooms into a series of puzzling challenges. However, rather than designing thought-provoking puzzles which would require careful solutions from the player, you'd much rather annoy them by crafting as tedious a gaming experience as possible.
The -th room is a grid of cells with rows and columns. You'll designate one of the cells to be the player's starting cell, and another one to be their destination. You may then choose some subset of the remaining cells to contain walls. The player's objective will then be to navigate from the starting cell to the destination cell by moving up, down, left, and right, without entering any cells that contain walls. Mazes are passable as puzzles, right?
Since your own objective is to make the players' lives miserable, you
want to design each room in such a way that the shortest possible path
from the starting cell to the destination cell is as long as possible.
The distance covered by a path between two cells is the number of
up/down/left/right moves that it involves. For each room, you'll need to
determine the maximum possible length of such a shortest path, and come
up with a room design (an arrangement of walls and starting/destination
cells) which yields that optimal distance between its starting and
destination cells. A room can be described as strings of
characters each, with the -th character of the -th string
representing the cell in the -th row and the -th column. The
single starting cell should be indicated with an S
, the single
destination cell with an E
, each wall with a #
, and each
remaining empty cell with a .
. If there exist multiple optimal room
designs, any of them will do.
In test cases worth of the points, .
In test cases worth another of the points, .
Input Specification
The first line of input consists of a single integer .
lines follow, the -th of which consists of a single integer
(for ).
Output Specification
For each room, output five lines. The first of these lines should
consist of a single integer – the largest possible shortest distance
between the starting and destination cells.
The last four of these lines shall describe any valid room design which
yields that optimal distance.
Sample Input
2
2
3
Sample Output
5
S.
#.
..
E#
8
...
.#E
..#
..S
Sample Explanation
Note that, for both rooms, there exist other valid room designs (besides the ones shown here) which would also yield the same optimal distances of and , and which would also be accepted.
Comments