A polyomino is a polyform with the square as its base form. It is a
connected shape formed as the union of one or more identical squares in
distinct locations on the plane, taken from the regular square tiling,
such that every square can be connected to every other square through a
sequence of shared edges (i.e., shapes connected only through shared
corners of squares are not permitted).
The most well-known polyominos are the seven tetrominos made out of four squares (see figure),
famous from the Tetris(R) 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.
Warn: 本題有 specialjudge
The input contains multiple test cases.
For each test case, there is one line with two positive integers h, w <= 10, and
next follows an h*w matrix of characters '.' or 'X', the 'X''s describing a polyomino and '.' space.
For each test case, if it is a k-power with 2 <= k <= 5 copies of a smaller polyomino, then output a h*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.
1 3 XXX 3 7 .XXXXX. .XX..X. XXXX... 4 9 .X..X.X.X .XX.X.X.X XXXXXXXXX .XX......
123 No solution .1..2.3.4 .15.2.3.4 115223344 .55......
Migrated from old NTUJ.
Nordic CPC 2010
No. | Testdata Range | Score |
---|