시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB96545358.889%

문제

Farmer Robert has been running a very successful cereal farm for many years. Now he wants to diversify his business and get into growing potatoes. To this end, he has bought a new plot of land on which he plans to plant the potatoes. This field is a rectangle and is exactly $\ell$ metres long and $w$ metres wide.

Since Robert is new to the potato business, he has initially purchased $n$ different potato varieties to try out in the first year. He plans to divide his plot of land into $n$ parts of equal area and plant one of the varieties on each. To make it easier for him to work the fields with his tractor, each new piece of land should itself be a rectangle and have integer side lengths. Help Robert to find a suitable division of his field.

입력

The input consists of:

  • One line with three integers $\ell, w, n$ ($1 \le \ell,w \le 100$, $1 \le n \le 26$), the length and width of Robert's field and the number of potato varieties.

출력

If there is no solution, output impossible. Otherwise output $\ell$ lines, each with $w$ uppercase letters, describing a possible division of Robert's field. There should be the same number of occurrences of each of the first $n$ letters of the English alphabet, and for each letter, its occurrences should form a single rectangular region. If there is more than one solution, any one of them will be accepted.

예제 입력 1

4 4 4

예제 출력 1

AAAA
BBCC
BBCC
DDDD

예제 입력 2

6 15 9

예제 출력 2

GGGGGBBBBBBBBBB
GGGGGAAAAAAAAAA
IIIIIIIIIIEEEEE
FFFFFFFFFFEEEEE
CCCCCDDDDDHHHHH
CCCCCDDDDDHHHHH

예제 입력 3

100 100 26

예제 출력 3

impossible

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2022 L번

  • 문제를 만든 사람: Paul Wild