题库练习 The Smallest String Concatenation
← 上一题 下一题 →

A10361 | The Smallest String Concatenation

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You're given a list of $n$ strings $a_{1},a_{2},\cdots,a_{n}$. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.

Given the list of strings, output the lexicographically smallest concatenation.

输入格式

The first line contains integer $n$ — the number of strings ( $1\leq n\leq 5\cdot 10^{4}$ ).

Each of the next $n$ lines contains one string $a_{i}$ ( $1\leq|a_{i}|\leq50$ ) consisting of only lowercase English letters. The sum of string lengths will not exceed $5\cdot 10^{4}$.

输出格式

Print the only string $a$ — the lexicographically smallest string concatenation.

输入输出样例

输入 #1
4
abba
abacaba
bcd
er
输出 #1
abacabaabbabcder
输入 #2
5
x
xx
xxa
xxaa
xxaaa
输出 #2
xxaaaxxaaxxaxxx
输入 #3
3
c
cb
cba
输出 #3
cbacbc
C++ 编辑器
输入
输出