#P10612. [BalticOI 2001] Box of Mirrors
[BalticOI 2001] Box of Mirrors
Problem Description
The mathematician Andris has a small box whose bottom is an grid. Each cell can contain a mirror oriented at degrees.
On the boundary of the box, at both ends of every row and every column, there are some holes. Light can enter the box through these holes and can also leave through them.


As shown above, a beam of light entering the box from hole is reflected twice and then leaves from hole .
Andris wants you to design a box so that the beam entering from each hole will leave from a specified hole.
For example, if he wants the beams entering from the holes to leave from holes respectively, then the box shown above also satisfies the requirement.
Note that the holes are numbered from to as shown in the figures.
Input Format
The first line contains two integers , representing the size of the box.
In the next lines, the -th line contains an integer , meaning that the beam entering from hole must leave from hole .
Output Format
Output an matrix. For each position, output to indicate no mirror is placed, and to indicate a mirror is placed. The output must satisfy the given requirements. The testdata guarantees that a solution always exists.
2 3
9
7
10
8
6
5
2
4
1
3
0 1 0
0 1 1
Hint
For of the testdata, , and .
Translated by ChatGPT 5