Codeforces 632C The Smallest String Concatenation 【string】
来源:互联网 发布:在家做淘宝客服兼职 编辑:程序博客网 时间:2024/05/17 22:03
C. The Smallest String Concatenation
time limit per test
3 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou'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.
Examples
input
4abbaabacababcder
output
abacabaabbabcder
input
5xxxxxaxxaaxxaaa
output
xxaaaxxaaxxaxxx
input
3ccbcba
output
cbacbc
题意:给你n个短串,让你组成一个字典序最小的串。
思路:string随便搞。
AC代码:
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <map>#include <string>#include <vector>#include <queue>#include <stack>#define CLR(a, b) memset(a, (b), sizeof(a))#define ll o<<1#define rr o<<1|1using namespace std;typedef long long LL;const int MOD = 1e9+7;const int MAXN = 5*1e4+10;const int INF = 0x3f3f3f3f;void add(LL &x, LL y) {x += y; x %= MOD;}string str[MAXN];bool cmp(string a, string b){ return a + b < b + a;}int main(){ int n; cin >> n; for(int i = 0; i < n; i++) cin >> str[i]; sort(str, str+n, cmp); for(int i = 0; i < n; i++) cout << str[i]; cout << endl; return 0;}
0 0
- Codeforces 632C - The Smallest String Concatenation
- CodeForces-632C-The Smallest String Concatenation
- CodeForces 632C The Smallest String Concatenation
- CodeForces 632C The Smallest String Concatenation
- Codeforces 632C The Smallest String Concatenation 【string】
- codeforces--623C The Smallest String Concatenation
- codeforces 632C C The Smallest String Concatenation(排序)
- CodeForces 632C C. The Smallest String Concatenation
- codeforces 632C The Smallest String Concatenation【巧妙的排序】
- CodeForces 632C The Smallest String Concatenation 排序
- CodeForces 632 C.The Smallest String Concatenation(水~)
- codeforces 632C The Smallest String Concatenation 排序
- The Smallest String Concatenation CodeForces 632C 字符串
- The Smallest String Concatenation CodeForces
- The Smallest String Concatenation CodeForces
- Codeforce 632C The Smallest String Concatenation
- C. The Smallest String Concatenation
- Educational Codeforces Round 9 -- C - The Smallest String Concatenation
- android PopupWindow的简单实用
- 50 Useful CSS Snippets Every Designer Should Have
- linux内核分析之-进程管理
- C语言中一些对文件操作的函数总结
- 最小值最大值算法
- Codeforces 632C The Smallest String Concatenation 【string】
- AJAX
- iOS学习之 - 文件下载
- 仅需6步,教你轻易撕掉app开发框架的神秘面纱(6):各种公共方法及工具类的封装
- Kobuki(turtlebot底盘)通信方式
- java调用第三方支付接口
- 计算指定时间与当前的时间差
- 【GDKOI2016】项链Code&Details
- ORCAD 创建原理图库