P26040 [AtCoder] [ABC366B] Vertical Writing
入门
题目描述

Problem Description

You are given a horizontally written text. Convert it to vertical writing. Fill the 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.

Output $ M $ strings $T_1, T_2, \dots, T_M$ that satisfy the following conditions:

  • Each $ T_i $ consists of lowercase English letters and *.
  • The end of each $ T_i $ is not *.
  • For each $1 \leq i \leq N$, the following holds:
  • For each $1 \leq j \leq |S_i|$, the $ N-i+1 $ character of $ T_j $ exists, and concatenating the $ N-i+1 $ characters of $T_1, T_2, \dots, T_{|S_i|}$ in this order results in $ S_i $.
  • For each $|S_i| + 1 \leq j \leq M$, the $ N-i+1 $ character of $ T_j $ is either non-existent or *.

Here, $ |S_i| $ denotes the length of string $ S_i $.

Input Format

The input is given from the standard input in the following format:

$ N $ $ S_1 $ $ S_2 $ $\vdots$ $ S_N $

Output Format

Output the answer in the following format:

$ T_1 $ $ T_2 $ $\vdots$ $ T_M $

Sample Input and Output

Sample Input #1

3
abc
de
fghi

Sample Output #1

fda
geb
h*c
i

Sample Input #2

3
atcoder
beginner
contest

Sample Output #2

cba
oet
ngc
tio
end
sne
ter
*r

Notes/Hints

Constraints

  • $ N $ is an integer between $ 1 $ and $ 100 $ inclusive.
  • $ S_i $ is a string of length between $ 1 $ and $ 100 $ consisting of lowercase English letters.

Sample Explanation 1

By making the second character of $ T_3 $ *, the c comes to the correct position. If the second and third characters of $ T_4 $ are *, the end of $ T_4 $ will be *, which does not satisfy the condition.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 abc de fghi
样例输出
fda geb h*c i