QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 2048 MB 總分: 100

#16821. 欢迎牌

统计

Amanda 正在镇上开一家新的面包店。她将在店面橱窗上挂一个精致的 LED 招牌,用来展示开业大吉的欢迎信息。该招牌有 $r$ 行和 $c$ 列显示单元。每个单元可以显示一个字母或保持空白。

Amanda 写了一条正好包含 $r$ 个单词的信息。她将把它们排列在 LED 招牌上,使得每一行按顺序显示信息中的一个单词。每个单词必须尽可能居中,这意味着如果单词左侧和右侧的空格数分别为 $l$ 和 $r$,那么 $|l - r|$ 必须尽可能接近于零。在那些 $l$ 不能等于 $r$ 的行中,Amanda 渴望平衡两侧的空格数量。更具体地说,对于第一条及之后每隔一条这样的行(即第 1、3、5 等个满足 $l \neq r$ 的行),她希望 $l$ 小于 $r$。对于其他这样的行(即第 2、4、6 等个满足 $l \neq r$ 的行),她希望 $l$ 大于 $r$。

在 Amanda 按照上述规则设置好招牌后,招牌看起来会是什么样子的?

输入格式

输入的第一行包含两个整数 $r$ 和 $c$($1 \le r, c \le 50$),分别表示显示单元的行数和列数。

接下来的 $r$ 行,每行包含一个单词,单词由至少一个且最多 $c$ 个小写字母(a–z)组成,按顺序给出每行要显示的单词。

输出格式

输出 $r$ 行。每行必须正好包含 $c$ 个字符,代表 LED 招牌上对应行的显示字符。用点号(.)表示每个空白的显示单元。

样例

输入样例 1

8 7
welcome
we
are
open
free
coffee
for
icpc

输出样例 1

welcome
..we...
..are..
..open.
.free..
.coffee
..for..
.icpc..

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.