303263: CF632C. The Smallest String Concatenation

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

The Smallest String Concatenation

题意翻译

给定 $n$ 个字符串,第 $i$ 个字符串为 $a_i$。求出一种依次连接这 $n$ 个字符串的顺序,使连接而成的字符串满足字典序最小。 输入格式: 第一行输入一个数 $n(1\leq n\leq 5\times 10^4)$,表示字符串数量。 接下来 $n$ 行中,每行输入一个小写英文字母串 $a_i(1\leq |a_i|\leq 50)$,字符串长度总和不超过 $5 \times 10^4$。 输出格式: 输出一行,包含一个字符串,为连接后字典序最小的字符串。

题目描述

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

Input

题意翻译

给定 $n$ 个字符串,第 $i$ 个字符串为 $a_i$。求出一种依次连接这 $n$ 个字符串的顺序,使连接而成的字符串满足字典序最小。 输入格式: 第一行输入一个数 $n(1\leq n\leq 5\times 10^4)$,表示字符串数量。 接下来 $n$ 行中,每行输入一个小写英文字母串 $a_i(1\leq |a_i|\leq 50)$,字符串长度总和不超过 $5 \times 10^4$。 输出格式: 输出一行,包含一个字符串,为连接后字典序最小的字符串。

加入题单

算法标签: