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.
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}$.
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