eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Japhshan and Ramshut

Japhshan and Ramshut

Today Japhshan and Ramshut are laying the pavement in front of Mrs. Kotchak's house. Pavement has the form of a rectangle of size \textbf{M}×\textbf{N}. Our workers have an infinite number of bricks of sizes \textbf{1}×\textbf{L_1}, \textbf{1}×\textbf{L_2}, ..., \textbf{1}×\textbf{L_K} at their disposal (the bricks were laying around unused at the nearby construction site). Your task is to find a way to compose a pavement out of these bricks (without holes and overlaps) or to determine that it is impossible. \InputFile The first line of input contains three integer numbers \textbf{N}, \textbf{M} and \textbf{K} (\textbf{M}, \textbf{N} ≥ \textbf{1}, \textbf{2} ≤ \textbf{M + N} ≤ \textbf{20}, \textbf{1} ≤ \textbf{K} ≤ \textbf{5}). Second line contains \textbf{K} numbers --- lengths of bricks. All brick lengths are positive and do not exceed \textbf{1000}. \OutputFile If it is possible to compose the pavement, output "\textbf{YES}" (without quotes) on the first line, then \textbf{N} lines of \textbf{M} lowercase Latin letters describing the composition. Two adjacent letters should be the same if they are related to the same brick, and different otherwise. If the composition is impossible, output "\textbf{NO}" (without quotes). If there is more than one way to compose the pavement, output any.
Ліміт часу 0.75 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
5 5 2
3 4
Вихідні дані #1
YES
bbbba
dccca
dbbba
dcccc
daaaa
Джерело Izhevsk STU Contest, Petrozavodsk training camp, February 6, 2009