今天本来应该要写校题解报告的,但是CF跪了,一题都没JUDGE出来,最后比赛取消了~郁闷啊!

后来闲的无事,就到处看看contest,随便点进去一个,看到一水题,几分钟写完,马上就WA了!~

题目的信息含量太低了!我直接看样例。以为是字典序排序后连起来输出,没想到是使得最后连起来的字典序最小。

本来我因为mutilset轻松水过,后来……还是用mutilset水的。重载下小于就好了。

题目:

Description





His Royal Highness King of Berland Berl XV was a very wise man and had a very accomplished wife, who was aware of the fact, that prominent and outstanding personalities once having written down their names on the pages of glorious History, remain there forever.
His Royal Highness King Berl XV experienced an intrinsic, lost nowadays, deep and sincere sense of respect and trust for his beloved spouse. So he decided to acquire a chronicler of his own. Due to the ambiguous nature of misunderstanding and the crying injustice
of history to ambiguity, he decided to leave all his royal responsibilities aside and made up his royal mind to find the chronicler, who will make him famous, depicting all his heroic deeds truthfully and gloriously enough.




The King assembled the greatest minds of his kingdom at the Academic Chroniclers Meeting (ACM), as he named it, and decided to test their might. The task was to build the Smallest Lexicographical Concatenation (SLC) out of the given
N strings. SLC of N strings s1,..., sN is the lexicographically smallest their concatenation
si1 +... + siN, where
i1,..., iN is a permutation of integers from 1 through
N. It's a great privilege to be a chronicler, so don't miss your chance and don't screw it up! Make the king choose you!

Input

The first line of the input file contains a single integer
N
(1 ≤ N ≤ 100) indicating the number of strings. The following
N
lines contain N strings, one string per line. The length of each string is no more than 100 characters. Each string consists only of lowercase Latin letters. There are no any leading or trailing spaces.

Output

Print the SLC of the given N strings to the output file as a single line.

Sample Input

sample input
sample output
6
it
looks
like
an
easy
problem
aneasyitlikelooksproblem

付代码

#include<iostream>
#include<set>
#include<string>
using namespace std;
class mstring{
public:
string str;
bool operator<(const mstring &t1) const{
return (str+t1.str < t1.str+str);
}
mstring(){};
mstring(string a){str=a;}; };
int main(){
multiset<mstring> s;
int n;
while(cin>>n){
s.clear();
string str;
cin.ignore();
while(n--){
cin>>str;
s.insert( mstring(str));
}
multiset<mstring> ::iterator itr =s.begin();
while(itr!=s.end()){ cout<<(*itr).str; itr++;
}
cout<<endl; } return 0;
}

注意到测试数据

2

ac

aca

排出来的应该是acaac 而不是acaca!

比较的方法就是 a+b<b+a!

每天一水SGU347的更多相关文章

  1. Openjudge 1.13-23:区间内的真素数(每日一水)

    总时间限制:  1000ms 内存限制:  65536kB 描述 找出正整数 M 和 N 之间(N 不小于 M)的所有真素数.真素数的定义:如果一个正整数 P 为素数,且其反序也为素数,那么 P 就为 ...

  2. poj2503--Babelfish(特里一水)

    Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 32988   Accepted: 14189 Descr ...

  3. 习题10-1 UVA 11040(无聊水一水)

    题意: 给你一个残缺的塔,每个数字由他下面左右两个数相加得.给你其中一部分,要求输出全部的数字. #include <iostream> #include <cstdio> # ...

  4. POJ 1321 棋盘问题 DFS 期末前水一水就好……

    A - 棋盘问题 Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  5. 每日一水 POJ8道水题

    1. POJ 3299 Humidex 链接: http://poj.org/problem?id=3299 这道题是已知H,D,T三者的运算关系,然后告诉你其中两个.求另一个. #include&l ...

  6. 数论E - Biorhythms(中国剩余定理,一水)

    E - Biorhythms Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Subm ...

  7. poj1936 假期计划第一水

    All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 29651   Accepted: 12312 Desc ...

  8. 每天一水poj1502【最短路】

    #include<iostream> #include<cstdio> #include<string.h> #include<algorithm> u ...

  9. codeforces346 Div.2 A.Round House

    课间水一水,CCF备战 package com.company.cf346; import java.io.InputStreamReader; import java.util.Scanner; / ...

随机推荐

  1. HW4.9

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. freemaker分页备忘

    思路:定义一个freemaker宏,接收参数.然后在freemaker页面上import这个文件,把参数传进来在server端渲染. 分页标签:pager.ftl <#-- 自定义的分页指令. ...

  3. Redis集群战法整理

    单机及集群搭建 http://www.codeceo.com/article/distributed-caching-redis-server.html 主从复制设置 Redis服务器复制(主—从配置 ...

  4. android ORMlite的应用

    ORMLite -轻量级的对象关系映射(ORM) 如果你需要在android中使用ORMLite 你需要进入官方网站http://ormlite.com/ 中下载 下载了这两个包以后,你还需要在对应的 ...

  5. 利用Splatting提交参数(Hash,哈希)

    $infos = @{} $infos.Path = 'c:\Windows' $infos.Recurse = $true $infos.Filter = '*.log' $infos.ErrorA ...

  6. 每天进步一点达——MySQL——myisampack

    一.        简单介绍 myisampack是一个压缩使用MyISAM引擎表的工具,通常会压缩40%~70%,当须要訪问数据.server会将所须要的信息读入到内存中.所以当訪问详细记录时,性能 ...

  7. java发送带附件的邮件

    /** * java发送带附件的邮件 * 周枫 * 2013.8.10 */ package com.dsideal.Util; import javax.mail.*; import javax.m ...

  8. 从div盒子模型谈如何写可维护的css代码(转)

    市面上我们常常会看到各种各样的设计模式书籍,Java设计模式.C#设计模式.Ruby设计模式等等.在众多的语言设计模式中我唯独找不到关于CSS设计模式的资料,即使在网上找到类似内容,细细一看之下才发觉 ...

  9. Error: no `server' JVM at...解决办法 【转】

    出现问题:用java -jar XXX.jar -server -Xms900m -Xmx900m 提示错误Error: no `server' JVM at `C:\Program Files\Ja ...

  10. sed命令详解--转

    1.简介 sed是非交互式的编辑器.它不会修改文件,除非使用shell重定向来保存结果.默认情况下,所有的输出行都被打印到屏幕上. sed编辑器逐行处理文件(或输入),并将结果发送到屏幕.具体过程如下 ...