103661: [Atcoder]ABC366 B - Vertical Writing
Description
Score : $200$ points
Problem Statement
You are given a horizontally written text. Convert it to vertical writing, filling spaces with
*
.
You are given $N$ strings $S_1, S_2, \dots, S_N$ consisting of lowercase English letters. Let $M$ be the maximum length of these strings.
Print $M$ strings $T_1, T_2, \dots, T_M$ that satisfy the following conditions:
- Each $T_i$ consists of lowercase English letters and
*
. - Each $T_i$ does not end with
*
. - For each $1 \leq i \leq N$, the following holds:
- For each $1 \leq j \leq |S_i|$, the $(N-i+1)$-th character of $T_j$ exists, and the concatenation of the $(N-i+1)$-th characters of $T_1, T_2, \dots, T_{|S_i|}$ in this order equals $S_i$.
- For each $|S_i| + 1 \leq j \leq M$, the $(N-i+1)$-th character of $T_j$ either does not exist or is
*
.
Here, $|S_i|$ denotes the length of the string $S_i$.
Constraints
- $N$ is an integer between $1$ and $100$, inclusive.
- Each $S_i$ is a string of lowercase English letters with length between $1$ and $100$, inclusive.
Input
The input is given from Standard Input in the following format:
$N$ $S_1$ $S_2$ $\vdots$ $S_N$
Output
Print the answer in the following format:
$T_1$ $T_2$ $\vdots$ $T_M$
Sample Input 1
3 abc de fghi
Sample Output 1
fda geb h*c i
Placing *
as the 2nd character of $T_3$ puts the c
in the correct position.
On the other hand, placing *
as the 2nd and 3rd characters of $T_4$ would make $T_4$ end with *
, which violates the condition.
Sample Input 2
3 atcoder beginner contest
Sample Output 2
cba oet ngc tio end sne ter *r
Output
得分:200分
问题陈述
给定一个水平书写的文本。将其转换为垂直书写,并用
*
填充空格。
给定由小写英文字母组成的$N$个字符串$S_1, S_2, \dots, S_N$。令$M$为这些字符串的最大长度。
打印$M$个字符串$T_1, T_2, \dots, T_M$,满足以下条件:
- 每个$T_i$由小写英文字母和
*
组成。 - 每个$T_i$不以
*
结尾。 - 对于每个$1 \leq i \leq N$,以下成立:
- 对于每个$1 \leq j \leq |S_i|$,$T_j$的第$(N-i+1)$个字符存在,并且按顺序连接$T_1, T_2, \dots, T_{|S_i|}$的第$(N-i+1)$个字符等于$S_i$。
- 对于每个$|S_i| + 1 \leq j \leq M$,$T_j$的第$(N-i+1)$个字符要么不存在,要么是
*
。
这里,$|S_i|$表示字符串$S_i$的长度。
约束条件
- $N$是一个在1到100之间(包含)的整数。
- 每个$S_i$是一个由小写英文字母组成的字符串,长度在1到100之间(包含)。
输入
输入从标准输入以以下格式给出:
$N$ $S_1$ $S_2$ $\vdots$ $S_N$
输出
以以下格式打印答案:
$T_1$ $T_2$ $\vdots$ $T_M$
示例输入1
3 abc de fghi
示例输出1
fda geb h*c i
将*
作为$T_3$的第2个字符,可以将c
放置在正确的位置。
另一方面,将*
作为$T_4$的第2个和第3个字符,将导致$T_4$以*
结尾,这违反了条件。
示例输入2
3 atcoder beginner contest
示例输出2
cba oet ngc tio end sne ter *r