Your task is to write a program that tiles a rectangle with tiles . For each one of the 26 uppercase letters, there exactly is a vertical tile and a horizontal tile available, of which can be used at most one. For instance, if and , we can use at most one of these two tiles:
The rectangle must be totally covered, and any piece of the used tiles can be left. If there are more than a way to tile, your prorgram must find the less in alphabetical order, reading from top to bottom and from left to right. In the case that does not exist any possible way, your program must indicate it.
The input consists of a series of lines, each one with , , and in this order. All the numbers are between 1 and 50.
For each line of the input, your program must print the least
lexicographically tiling, or "!!!" if does not exist any.
Separate the answers with a line in white.
TestA:
Some test cases will exclusively contain cases like the ones in the instance of input 1, in which , and where and are multiples of .
TestB:
Some test cases will also contain cases like the ones in the instance of input 2, in which and are multiples of and .
TestC:
Other test cases will contain cases of every kind.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T12:13:29.155Z
© Jutge.org, 2006–2026.
https://jutge.org