The Smallest String Concatenation

题目链接:http://codeforces.com/problemset/problem/632/C

    ——每天在线,欢迎留言谈论。

题目大意:

给你n个字符串,相加后 字典序最小

思路:

只需要保证每个相邻的两个字符串组合后 s1+s2>s2+s1 即可。

用sort()快速排序,最后依次输出即可!

AC代码:

 #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int MAXN=5e4+;
string ss[MAXN];
bool cmp(string s1,string s2)
{
return s1+s2<s2+s1;
}
int main()
{
int n;
cin>>n;
for(int i=;i<n;i++)
cin>>ss[i];
sort(ss,ss+n,cmp);
for(int i=;i<n;i++)
cout<<ss[i];
cout<<endl;
return ;
}

2017-05-07 19:20:25

codeforces 632C The Smallest String Concatenation的更多相关文章

  1. CodeForces 632C The Smallest String Concatenation//用string和sort就好了&&string的基础用法

    Description You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them togethe ...

  2. codeforces 632C. The Smallest String Concatenation 排序

    题目链接 给出n个字符串, 将他们连在一起, 求连玩之后字典序最小的那种情况. 按a+b<b+a排序.... #include <iostream> #include <vec ...

  3. codeforces 632C C. The Smallest String Concatenation(sort)

    C. The Smallest String Concatenation time limit per test 3 seconds memory limit per test 256 megabyt ...

  4. Educational Codeforces Round 9 C. The Smallest String Concatenation 排序

    C. The Smallest String Concatenation 题目连接: http://www.codeforces.com/contest/632/problem/C Descripti ...

  5. Educational Codeforces Round 9 C. The Smallest String Concatenation —— 贪心 + 字符串

    题目链接:http://codeforces.com/problemset/problem/632/C C. The Smallest String Concatenation time limit ...

  6. Educational Codeforces Round 9 C. The Smallest String Concatenation(字符串排序)

    You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some or ...

  7. C. The Smallest String Concatenation

    C. The Smallest String Concatenation time limit per test 3 seconds memory limit per test 256 megabyt ...

  8. C. The Smallest String Concatenation-C++sort排序~~

    C. The Smallest String Concatenation time limit per test 3 seconds memory limit per test 256 megabyt ...

  9. Effective Java 51 Beware the performance of string concatenation

    Using the string concatenation operator repeatedly to concatenate n strings requires time quadratic ...

随机推荐

  1. 项目总结三:目标检测项目(Car detection with YOLOv2)

    1. the YOLO model (YOLO ,you only look once) (1)We will use 5 anchor boxes. So you can think of the ...

  2. 《JQuery技术内幕》读书笔记——自调用匿名函数剖析

    Javascript语言中的自调用匿名函数格式如下: (function(){ //do somethings })(); 它还有另外两种等价写法如下: //等价写法一 (function(){ // ...

  3. 使用.NET Hardware Intrinsics API加速机器学习场景

    ML.NET 0.6版本刚刚发布不久,我们知道ML.NET代码已经依赖于使用本机代码库的性能矢量化.这是一个重新实现托管代码中现有代码库的机会,使用.NET Hardware Intrinsics进行 ...

  4. mysql 开发进阶篇系列 10 锁问题 (相同索引键值或同一行或间隙锁的冲突)

    1.使用相同索引键值的冲突 由于mysql 的行锁是针对索引加的锁,不是针对记录加的锁,所以虽然是访问不同行的记录,但如果是使用相同的索引键,是会出现锁冲突的.设计时要注意 例如:city表city_ ...

  5. 项目中使用sass,如何实现自动编译

    本次React项目中用到了Sass,在一个主文件main.scss中引入了其余的scss文件,然后把main.scss文件编译为main.css文件,最后在项目的主文件入口index.html中引入m ...

  6. Log4Net在MVC下的配置以及运用线程队列记录异常信息

    Log4Net是用来记录日志的,可以将程序运行过程中的信息输出到一些地方(文件.数据库.EventLog等),日志就是程序的黑匣子,可以通过日志查看系统的运行过程,从而发现系统的问题.日志的作用:将运 ...

  7. iOS逆向开发(5):微信强制升级的突破 | 多开 | 微信5.0

    接下来的几篇文章,小程以微信为例,实战地演示一下:如何注入iOS的APP.其中使用到的知识,基本在前面的文章中都有介绍到. 小白:小程,我想用回旧版本的微信! 小程:为什么要用旧版本微信呢? 小白:你 ...

  8. PYTHON 中 SQL 带参数

    使用 PYTHON 的字符串填充方式 import mysql.connector sql = 'select \* from school.student where age > {age} ...

  9. 翻译:insert select(已提交到MariaDB官方手册)

    本文为mariadb官方手册:insert select的译文. 原文:https://mariadb.com/kb/en/insert-select/ 我提交到MariaDB官方手册的译文:http ...

  10. zepto中的属性设置

    上次看zepto的init方法时,有一段属性设置的代码,先来看看其表现: if (isPlainObject(properties)) { nodes = $(dom) $.each(properti ...