测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10361. The Smallest String Concatenation

编程题 普及/提高-

题目描述

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
上一题 去做题 下一题