题目链接:http://abc042.contest.atcoder.jp/tasks/abc042_b

Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

Iroha has a sequence of N strings S1,S2,…,SN. The length of each string is L.

She will concatenate all of the strings in some order, to produce a long string.

Among all strings that she can produce in this way, find the lexicographically smallest one.

Here, a string s=s1s2s3...sn is lexicographically smaller than another string t=t1t2t3...tm if and only if one of the following holds:

  • There exists an index i(1≦imin(n,m)), such that sj=tj for all indices j(1≦j<i), and si<ti.
  • si=ti for all integers i(1≦imin(n,m)), and n<m.

Constraints

  • 1≦N,L≦100
  • For each i, the length of Si equals L.
  • For each iSi consists of lowercase letters.

Input

The input is given from Standard Input in the following format:

N L
S1
S2
:
SN

Output

Print the lexicographically smallest string that Iroha can produce.


Sample Input 1

Copy
3 3
dxx
axx
cxx

Sample Output 1

Copy
axxcxxdxx

The following order should be used: axxcxxdxx.

题解:大致意思是是对字符串排序然后顺序输出 尝试用了下字符串的优先队列 以为会哇一发 没想到居然过了

   可是我用优先队列之后 感觉 L 这个数据就废了啊 也没看其他的做法 不知道有没有用它

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
return x>y;
}
const int N=;
const int mod=1e9+;
int main()
{
std::ios::sync_with_stdio(false);
int n,l;
cin>>n>>l;
string a;
priority_queue<string,vector<string>,greater<string> >q;
for(int i=;i<n;i++){
cin>>a;
q.push(a);
}
while(q.size()>){
string b=q.top();
cout<<b;
q.pop();
}
cout<<endl;
return ;
}

文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition) (优先队列)的更多相关文章

  1. Atcoder Regular Contest 058 D - 文字列大好きいろはちゃん / Iroha Loves Strings(单调栈+Z 函数)

    洛谷题面传送门 & Atcoder 题面传送门 神仙题. mol 一发现场(bushi)独立切掉此题的 ycx %%%%%%% 首先咱们可以想到一个非常 naive 的 DP,\(dp_{i, ...

  2. 题解-ARC058D Iroha Loves Strings

    题面 ARC058D Iroha Loves Strings 给定 \(n\) 个字符串,从中选出若干个按给出顺序连接起来,总长等于 \(m\),求字典序最小的,保证有解. 数据范围:\(1\le n ...

  3. 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition) (水水)

    题目链接:http://abc042.contest.atcoder.jp/tasks/abc042_a Time limit : 2sec / Memory limit : 256MB Score ...

  4. CONCATENATE命令(文字列の結合)

    CONCATENATE命令とは文字列の結合を行う命令である.文字列を扱うChar, Numeric, Dats, Time, Stringの変数で使用する事が可能だ.単純に文字列の結合のみを行う方法. ...

  5. Codeforces Round #FF (Div. 2):B. DZY Loves Strings

    B. DZY Loves Strings time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. [CodeForces - 447B] B - DZY Loves Strings

    B - DZY Loves Strings DZY loves collecting special strings which only contain lowercase letters. For ...

  7. Codeforces Round #254 (Div. 1) D - DZY Loves Strings

    D - DZY Loves Strings 思路:感觉这种把询问按大小分成两类解决的问题都很不好想.. https://codeforces.com/blog/entry/12959 题解说得很清楚啦 ...

  8. Codeforces Round #254 (Div. 1) D. DZY Loves Strings hash 暴力

    D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings ...

  9. SHIFT(文字列の指定位置数の移動)

    文字ごとの項目内容の移動 以下のような SHIFT 命令のバリアントを使用すると.項目内容を移動することができます.SHIFT を使用すると.文字ごとに項目内容が移動します. 文字列の指定位置数の移動 ...

随机推荐

  1. vc让界面保持最上层

    vc让界面保持最上层.事实上就一个函数就ok了, ::SetWindowPos(AfxGetMainWnd()->m_hWnd,HWND_TOPMOST,-1,-1,-1,-1,0);

  2. Linux系统启动和内核管理

    Linux组成 由 kernel 和 rootfs 组成 单内核:(进程管理,内存管理,网络管理, 驱动程序,文件系统, 安全功能) /boot/vmlinuz-VERSION-release 辅助的 ...

  3. Windows 7中200M神秘隐藏分区

    裸机全新安装Windows 7的用户,在安装完成后运行diskmgmt.msc打开磁盘管理器,可以看到在系统分区(一般为C分区)之前有一个大小为200MB的隐藏分区.这个特殊的隐藏分区与Windows ...

  4. 利用 SPL 快速实现 Observer 设计模式

    目录: 1.什么是 SPL 2.SplSubject 和 SplObserver 接口 3.为什么使用 SplObjectStorage 类 4.模拟案例 5.结束语 6.下载资源 什么是 SPL S ...

  5. springboot + mybatis配置分页插件

    一:使用pagehelper配置分页插件 1:首先配置springboot +mybatis框架  参考:http://www.cnblogs.com/liyafei/p/7911549.html 2 ...

  6. Spring Boot下的lombok安装以及使用简介

    引言:lombok是一套代码模板解决方案,将极大提升开发的效率,这里介绍给大家使用. 1. Lombok lombok是一个可以通过简单的注解的形式来帮助我们简化消除一些必须有但显得很臃肿的 Java ...

  7. python 类组合

    场景:有一辆车违章需要通知到车主 定义两个类车辆类和通知类,车辆类和通知类并没有共同点,但是要通知车主这两个类就有了关联,这时候可以把这两个类组合在一起 #!/usr/bin/python3 # -* ...

  8. IOC解耦-面向接口编程的优点

    原文:https://blog.csdn.net/jj_nan/article/details/70161086 参考:https://www.cnblogs.com/landeanfen/p/477 ...

  9. 用python.twisted.logfile每天记录日志,并用不记录stdout中的内容

    #导入的头 from twisted.python import logfrom twisted.python.logfile import * #开始记录,输入日志名和存放的路径,setStdout ...

  10. 强势龙头股的 VOLM5/35/135 走势,可作为逃顶参考

    强势龙头股的 VOLM5/35/135 走势,可作为逃顶参考