CF632C.The Smallest String Concatenation
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You're given a list of n strings _a_1, _a_2, ..., 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.
给你一个包含 n 个字符串的列表:_a_₁, _a_₂, ..., a__n。你希望以某种顺序将它们连接起来,使得最终得到的字符串在字典序上最小。
给定该字符串列表,请输出字典序最小的连接结果。
输入格式
The first line contains integer n — the number of strings (1 ≤ n ≤ 5·104).
Each of the next n lines contains one string a__i (1 ≤ |a__i| ≤ 50) consisting of only lowercase English letters. The sum of string lengths will not exceed 5·104.
第一行包含一个整数 n — 字符串的数量(1 ≤ n ≤ 5⋅104)。
接下来的 n 行中,每行包含一个字符串 ai(1 ≤ ∣ai∣ ≤ 50),且每个字符串仅由小写英文字母组成。所有字符串的长度之和不超过 5⋅104。
输出格式
Print the only string a — the lexicographically smallest string concatenation.
输出唯一的字符串 a —— 字典序最小的字符串拼接结果。
输入输出样例
输入#1
4 abba abacaba bcd er
输出#1
abacabaabbabcder
输入#2
5 x xx xxa xxaa xxaaa
输出#2
xxaaaxxaaxxaxxx
输入#3
3 c cb cba
输出#3
cbacbc
输入解题思路,AI测评打分。不知道怎么写?