CF632C.The Smallest String Concatenation
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You're given a list of n strings a1,a2,⋯,an. 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≤n≤5⋅104 ).
Each of the next n lines contains one string ai ( 1≤∣ai∣≤50 ) consisting of only lowercase English letters. The sum of string lengths will not exceed 5⋅104.
输出格式
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