E - The Smallest String Concatenation

CodeForces - 632C

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.

Example

Input
4
abba
abacaba
bcd
er

Output
abacabaabbabcder

Input
5
x
xx
xxa
xxaa
xxaaa

Output
xxaaaxxaaxxaxxx

Input
3
c
cb
cba

Output
cbacbc

猪大脑哦....两个字符串连接起来最短.......当然就是这个样子比较简单~~~~

代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5*1e4+100;
string s[maxn];
bool cmp(string a,string b){return a+b<b+a;
}
int main()
{int n;scanf("%d",&n);for(int i=1;i<=n;i++){cin>>s[i];}sort(s+1,s+1+n,cmp);for(int i=1;i<=n;i++)cout<<s[i];cout<<endl;return 0;
}

CodeForces 632C The Smallest String Concatenation(水)相关推荐

  1. 【Codeforces - 632C】The Smallest String Concatenation (对string巧妙排序)

    题干: You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in som ...

  2. oracle11g ora 29927,listagg函数 ORA-01489 result of string concatenation is too long的解决办法 【博森瑞】...

    listagg函数 ORA-01489: result of string concatenation is too long的解决办法 概述 listagg 函数是Oracle 11g推出的一个分组 ...

  3. Codeforces Problem-1579A Casimir‘s String Solitaire

    Codeforces Problem-1579A Casimir's String Solitaire 题目链接 题目大意: Casimir有一个字符串s,里面只包含'A''B''C'三种字符,现在他 ...

  4. overloading 重载 String concatenation BlueJ 的 Code Pad

    Overloading 重载 这是一个打票机 import lang.stride.*;public class TicketMachine {/* The price of a ticket fro ...

  5. oracle ora32771,listagg函数 ORA-01489: result of string concatenation is too long的解决办法

    概述 listagg函数是Oracle 11g推出的一个分组函数,可以将字符串按分组连接起来. SQL> select deptno ,listagg(ename,'->') within ...

  6. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  7. 【CodeForces - 1A】Theatre Square(水题,几何)(CODEFORCES,梦的开始)

    题干: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters ...

  8. Codeforces Round #300 A. Cutting Banner 水题

    A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...

  9. codeforces 960A Check the string

    题目链接:http://codeforces.com/contest/960/problem/A 题意:有A,B,C三个小朋友,A会把一个全为a的字符串给B,然后B会在这个字符串尾添加若干个b,然然后 ...

  10. Educational Codeforces Round 96 E. String Reversa 线段树模拟序列交换

    传送门 文章目录 题意: 思路: 题意: 思路: 与上一篇题解大同小异,无非就是不需要枚举排列了. // Problem: E. String Reversal // Contest: Codefor ...

最新文章

  1. win7网站服务器空间怎么清理,win7如何清理c盘空间_win7磁盘空间不足怎么清理
  2. mysql调优的一些方面
  3. wordpress 外部数据接口_使用接口方式获取WordPress用户信息的方法
  4. Makefile学习(三)[第二版]
  5. jq 封装弹窗提示框,自动消失,确认
  6. 如何展开Linux Memory Management学习?
  7. 计算机网络 故障处理,计算机网络通讯技术故障分析与处理
  8. 每日算法系列【LeetCode 233】数字 1 的个数
  9. cisco将计算机配置为vlan2,Cisco交换机 VLAN 的建立与端口分配
  10. ubuntu 的 kitti2bag安装与测试
  11. 坑爹的工行Chrome网银插件
  12. 【jQuery】jQuery本地时间与世界时间时差转换
  13. 三维重建 | 单张RGB图片生成三维网格模型
  14. 电大管理英语4计算机期末考试,2021国家开放大学电大本科《管理英语4》期末试题及答案(试卷号:1389)...
  15. 校园二手交易平台-程序流程图
  16. APP怎样通过免填邀请码,提高App邀请效率?
  17. 勇敢做自己,女神节快乐!
  18. 行转列,把三行四列转换为四行三列并输出 (C语言)
  19. 苹果听天由命 未雇佣游说公司处理欧盟补税案
  20. fairyGUI的学习记录1

热门文章

  1. leetcode讲解--937. Reorder Log Files
  2. iOS图形处理概论:OpenGL ES,Metal,Core Graphics,Core Image,GPUImage,OpenCV等
  3. C#中取得汉语拼音首字母
  4. UVA 1252 十五 Twenty Questions
  5. 强烈推荐!大数据领域的顶级开源工具大集合
  6. 关于网络安全检查的问题
  7. myeclipse 报内存不足的解决方法
  8. CentOS 6.5下安装Docker
  9. windows 上面的tensorflow-GPU、cuda、cudnn 安装
  10. python 2个dict如何合并