Welcome Sign
시간 제한1초메모리 제한2048 MB
r개의 단어를 너비 c의 각 행에 가운데 정렬로 배치하고, 남는 칸이 홀수일 때 좌우 어느 쪽에 빈칸을 더 둘지 번갈아 정한다.
문제
Amanda is opening a new bakery in town. She will put up a fancy LED sign to show a grand opening message on the storefront window. The sign has rows and columns of display units. Each unit can display one letter or be blank.
Amanda has written a message consisting of exactly words. She will arrange them onto the LED sign such that each row will display one word from the message in order. Each word must be as centered as possible, which means that if the number of blanks on the left side and right side of the word are and , then must be as close to zero as possible. On those rows where cannot equal , Amanda would like to balance the number of blanks on the two sides. More specifically, for the first and every other such row (st, rd, th, and so forth), she would like to be less than . For the other rows (nd, th, th, and so forth), she would like to be greater than .
What would the sign look like after Amanda sets it up according to the above?
입력
The first line of input contains two integers and (), the number of rows and the number of columns of display units.
The next lines each contain a word with at least one and at most lowercase letters (a-z), giving the words to display per row in order.
출력
Output lines. Each line must contain exactly characters representing the displayed characters on one row of the LED sign. Output a dot (.) for each blank display unit.