You have square tiles, each painted with a color codified with a number. You will have to use the tiles to cover a floor of dimensions , with just one restriction: there cannot be two or more (horizontal or vertical) adjacent tiles of the same color. Can you find a solution?
Input consists of several cases, each with and , followed by numbers, all between 1 and . Assume .
For each case, if there is no solution, print a line with
“NO”. Otherwise, print a line with “YES”,
followed by
lines with
numbers each. If there is more than one solution, you can print any one.
Follow strictly the format of the sample output.
Author: Salvador Roura
Generation: 2026-01-25T11:56:42.604Z
© Jutge.org, 2006–2026.
https://jutge.org