CodeForces 632C The Smallest String Concatenation(水)
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
4 abba abacaba bcd er
abacabaabbabcder
5 x xx xxa xxaa xxaaa
xxaaaxxaaxxaxxx
3 c cb cba
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(水)相关推荐
- 【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 ...
- 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推出的一个分组 ...
- Codeforces Problem-1579A Casimir‘s String Solitaire
Codeforces Problem-1579A Casimir's String Solitaire 题目链接 题目大意: Casimir有一个字符串s,里面只包含'A''B''C'三种字符,现在他 ...
- overloading 重载 String concatenation BlueJ 的 Code Pad
Overloading 重载 这是一个打票机 import lang.stride.*;public class TicketMachine {/* The price of a ticket fro ...
- oracle ora32771,listagg函数 ORA-01489: result of string concatenation is too long的解决办法
概述 listagg函数是Oracle 11g推出的一个分组函数,可以将字符串按分组连接起来. SQL> select deptno ,listagg(ename,'->') within ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- 【CodeForces - 1A】Theatre Square(水题,几何)(CODEFORCES,梦的开始)
题干: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters ...
- Codeforces Round #300 A. Cutting Banner 水题
A. Cutting Banner Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...
- codeforces 960A Check the string
题目链接:http://codeforces.com/contest/960/problem/A 题意:有A,B,C三个小朋友,A会把一个全为a的字符串给B,然后B会在这个字符串尾添加若干个b,然然后 ...
- Educational Codeforces Round 96 E. String Reversa 线段树模拟序列交换
传送门 文章目录 题意: 思路: 题意: 思路: 与上一篇题解大同小异,无非就是不需要枚举排列了. // Problem: E. String Reversal // Contest: Codefor ...
最新文章
- win7网站服务器空间怎么清理,win7如何清理c盘空间_win7磁盘空间不足怎么清理
- mysql调优的一些方面
- wordpress 外部数据接口_使用接口方式获取WordPress用户信息的方法
- Makefile学习(三)[第二版]
- jq 封装弹窗提示框,自动消失,确认
- 如何展开Linux Memory Management学习?
- 计算机网络 故障处理,计算机网络通讯技术故障分析与处理
- 每日算法系列【LeetCode 233】数字 1 的个数
- cisco将计算机配置为vlan2,Cisco交换机 VLAN 的建立与端口分配
- ubuntu 的 kitti2bag安装与测试
- 坑爹的工行Chrome网银插件
- 【jQuery】jQuery本地时间与世界时间时差转换
- 三维重建 | 单张RGB图片生成三维网格模型
- 电大管理英语4计算机期末考试,2021国家开放大学电大本科《管理英语4》期末试题及答案(试卷号:1389)...
- 校园二手交易平台-程序流程图
- APP怎样通过免填邀请码,提高App邀请效率?
- 勇敢做自己,女神节快乐!
- 行转列,把三行四列转换为四行三列并输出 (C语言)
- 苹果听天由命 未雇佣游说公司处理欧盟补税案
- fairyGUI的学习记录1