| NUS CS3233 Final Team Contest 2024 |
|---|
| Finished |
Consider a grid of $$$n$$$ columns and $$$m$$$ rows. Number the columns from $$$0$$$ to $$$n-1$$$ from left to right.
Within the grid, some double-sided mirrors of the form "\" or "/" are placed.
When a laser is shined from the top, it will travel down the grid and might get reflected through the mirrors. For example:
In the example above, the laser ray entering column $$$2$$$ from the top travels out at column $$$4$$$ at the bottom.
Given an integer $$$n$$$ and a permutation $$$p = (p_0, p_1, \dots, p_{n-1})$$$ of $$$\{ 0, 1, \dots, n-1 \}$$$. Find a grid with the minimum nonnegative number of rows $$$m$$$, such that for every $$$i = 0, \dots, n-1$$$, the laser entering column $$$i$$$ from the top will travel out at column $$$p_i$$$ at the bottom.
There will be multiple test cases, terminated by EOF.
For each test case: The first line contains a positive integer $$$n$$$, the second line contains $$$n$$$ space-separated integers, $$$p_0\ p_1\ \dots\ p_n$$$.
For each test case, print the number of rows $$$m$$$ on the first line. The $$$m$$$ subsequent lines should contain the mirror configurations of each row, using character "\", "/" or "." (without quotes) to represent each cell.
For example, the image above corresponding to the following output:
3
.../
./..
.../.
If there are multiple possible configurations, output any of them.
Each file has at least one test case.
The sum of $$$n$$$ for each file does not exceed $$$10^4$$$.
The output file size does not exceed $$$5 \cdot 10^6$$$ bytes.
1 0 5 1 2 3 4 0
0 1 \\\\\
| Name |
|---|


