博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Educational Codeforces Round 9 C. The Smallest String Concatenation 排序
阅读量:7202 次
发布时间:2019-06-29

本文共 965 字,大约阅读时间需要 3 分钟。

C. The Smallest String Concatenation

题目连接:

Description

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.

Input

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.

Output

Print the only string a — the lexicographically smallest string concatenation.

Sample Input

4

abba
abacaba
bcd
er

Sample Output

abacabaabbabcder

Hint

题意

给你n个串,然后你要组合这n个串,使得n个串的字典序最小

题解:

写个CMP就好了~

代码

#include
using namespace std;const int maxn = 5e4+5;string s[maxn];bool cmp(string a,string b){ string ab = a+b; string ba = b+a; return ab
>s[i]; sort(s,s+n,cmp); for(int i=0;i

转载地址:http://erwum.baihongyu.com/

你可能感兴趣的文章
基于MVC+EasyUI的Web开发框架经验总结(10)--在Web界面上实现数据的导入和导出...
查看>>
Mysql数据库视图操作
查看>>
[培训]薛大龙@福建福州(2008.7.24-25)
查看>>
Linux运维学习历程-第十四天-磁盘管理(一)磁盘分区表类型与文件系统
查看>>
2016年4月20日作业
查看>>
4、Ansible配置和使用
查看>>
如何设计EDM邮件内容
查看>>
java_类型转换(转)
查看>>
EMC 存储 故障转移模式(Failover Mode)简介
查看>>
解决iis服务器 Server Application Error
查看>>
wget
查看>>
openjdk安装二
查看>>
信息、信息化与信息化营销
查看>>
https的网站用了百度分享后网站在浏览器中不安全解决方法
查看>>
我的友情链接
查看>>
Oracle shutdown immediate无法关闭数据库解决方法
查看>>
MySQL5.7杀手级新特性:GTID原理与实战
查看>>
iOS 分类思想(1)
查看>>
键盘中每个键的作用你知多少?
查看>>
HTML模板
查看>>