第 042 场 AtCoder Beginner Contest
B
Iroha 喜爱字符串(ABC 版)
Iroha Loves Strings (ABC Edition)
AtCoder
⌀ 616
原题
← A→

Iroha 喜爱字符串(ABC 版)AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

Iroha has a sequence of $N$ strings $S_1, S_2, ..., S_N$. The length of each string is $L$.

Iroha 有一个由 $N$ 个字符串 $S_1, S_2, ..., S_N$ 组成的序列。每个字符串的长度均为 $L$。AI (CI翻译)

She will concatenate all of the strings in some order, to produce a long string.

她将按某种顺序拼接所有字符串,得到一个长字符串。AI (CI翻译)

Among all strings that she can produce in this way, find the lexicographically smallest one.

请找出她能以这种方式得到的所有字符串中字典序最小的字符串。AI (CI翻译)

Here, a string $s=s_1s_2s_3$...$s_n$ is lexicographically smaller than another string $t=t_1t_2t_3$...$t_m$ if and only if one of the following holds:

这里,字符串 $s=s_1s_2s_3$...$s_n$ 的字典序小于另一个字符串 $t=t_1t_2t_3$...$t_m$,当且仅当以下条件之一成立:AI (CI翻译)

  • There exists an index $i(1≦i≦min(n,m))$, such that $s_j = t_j$ for all indices $j(1≦j<i)$, and $s_i<t_i$.
  • $s_i = t_i$ for all integers $i(1≦i≦min(n,m))$, and $n<m$.
  • 存在一个下标 $i(1≦i≦min(n,m))$,使得对于所有下标 $j(1≦j<i)$,都有 $s_j = t_j$,且 $s_i<t_i$。
  • 对于所有整数 $i(1≦i≦min(n,m))$,都有 $s_i = t_i$,且 $n<m$。
AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 ≦ N, L ≦ 100$
  • For each $i$, the length of $S_i$ equals $L$.
  • For each $i$, $S_i$ consists of lowercase letters.
  • $1 ≦ N, L ≦ 100$
  • 对于每个 $i$,$S_i$ 的长度均为 $L$。
  • 对于每个 $i$,$S_i$ 均由小写字母组成。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入通过标准输入给出,格式如下:AI (CI翻译)

N L
S_1
S_2
:
S_N

N L
S_1
S_2
:
S_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Print the lexicographically smallest string that Iroha can produce.

输出 Iroha 能得到的字典序最小的字符串。AI (CI翻译)

样例

Input #1
3 3
dxx
axx
cxx
Output #1
axxcxxdxx
The following order should be used: `axx`, `cxx`, `dxx`.
题目信息
题号
abc042_b
时间限制
2 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。