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. chrome强制刷新,非ctrl+f5

    开发时,经常有ctrl+f5无法做到真正的强制刷新,以下可以帮到你 Ctrl+Shift+Del 清除Google浏览器缓存的快捷键 Ctrl+Shift+R 重新加载当前网页而不使用缓存内容

  2. 【shiro】(5)---基于Shiro的权限管理

    基于Shiro的权限管理项目搭建 前面写了四篇有关权限的文章,算是这篇文章的铺垫了.这篇文章采用 开发环境           JDK1.8          Eclipse          Mav ...

  3. Asp.net core 环境配置

    参考: 在 ASP.NET Core 中使用多个环境 ASP.NET Core 中的配置 在项目的 Properties\launchSettings.json中可以配置多个环境 { "ii ...

  4. 微信分享config:ok 但自定义内容无效

    一.问题 使用微信 JSSDK 分享,出现自定义内容无效 ,也就是分享出去的内容不是你配置的内容. 但在调试过程中发现 congfig 都是 ok 的 二.解决 检查config 配置是否正确 js ...

  5. Salesforce Sales Cloud 零基础学习(一) Product 和 Price Book

    以前的博客大部分都是基于force.com以及lightning展开的自定义开发,其实salesforce提供了很多的标准的功能以及平台, Sales Cloud便是作为Salesforce核心的平台 ...

  6. Java生成sitemap网站地图

    访问我的博客 sitemap 是什么?对应没有接触过网站 SEO 的同学可能不知道,这里引用一下百度站长的一段解释. Sitemap(即站点地图)就是您网站上各网页的列表.创建并提交Sitemap有助 ...

  7. python三大神器之pip

    pip是一款管理python各类包和库的工具,非常好用.下文介绍常用的一些命令. ● 安装:pip install 库名 也可以指定版本:pip install 库名=版本 ● 卸载:pip unin ...

  8. Mybatis的SqlSession运行原理

    前言 SqlSession是Mybatis最重要的构建之一,可以简单的认为Mybatis一系列的配置目的是生成类似 JDBC生成的Connection对象的SqlSession对象,这样才能与数据库开 ...

  9. Django 系列博客(一)

    Django 系列博客(一) 前言 学习了 python 这么久,终于到了Django 框架.这可以说是 python 名气最大的web 框架了,那么从今天开始会开始从 Django框架的安装到使用一 ...

  10. js_ajax模拟form表单提交_多文件上传_支持单个删除

    需求场景: 用一个input type="file"按钮上传多张图片,可多次上传,可单独删除,最后使用ajax模拟form表单提交功能提交到指定方法中: 问题:由于只有一个file ...