Problem A
Polyomino Powers
![/problems/polyomino/file/statement/en/img-0001.jpg](/problems/polyomino/file/statement/en/img-0001.jpg)
The most well-known polyominos are the seven tetrominos made out of four squares (see figure), famous from the Tetris® game, and of course the single domino consisting of two squares from the game with the same name. Some polyomino can be obtained by gluing several copies of the same smaller polyomino translated (but not rotated or mirrored) to different locations in the plane. We call those polyomino powers.
Input
One line with two positive integers $h, w \leq 10$. Next follows an $h \times w$ matrix of characters ‘.’ or ‘X’, the ‘X’s describing a polyomino and ‘.’ space.
Output
A $k$-power with $2 \leq k \leq 5$ copies of a smaller polyomino: Output a $h\times w$ matrix on the same format as the input with the ‘X’s replaced by the numbers $1$ through $k$ in any order identifying the factor pieces. Furthermore, if multiple solutions exist, any will do. Otherwise, output “No solution” if no solution exists.
Sample Input 1 | Sample Output 1 |
---|---|
3 7 .XXXXX. .XX..X. XXXX... |
No solution |
Sample Input 2 | Sample Output 2 |
---|---|
1 3 XXX |
123 |
Sample Input 3 | Sample Output 3 |
---|---|
4 9 .X..X.X.X .XX.X.X.X XXXXXXXXX .XX...... |
.1..2.3.4 .15.2.3.4 115223344 .55...... |