今天本来应该要写校题解报告的,但是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. Native code - how to get function call stack (backtrace) programatically 附带源代码

    自己根据 https://github.com/zhuowei/libcorkscrew-ndk 上的库做了一个包装库并附带使用的例子(executable 分支),具体代码在自己的代码仓库里,名字叫 ...

  2. linux c 及 c++打印调用者函数caller function的方法,包括arm c平台

    一般情况下,编译的时候可能需要加 -g 选项,对于android ndk的-g选项添加请参见android类目下的另一篇文章. 以下文章中的__builtin_return_address() 宏,若 ...

  3. ZOJ3471--Most Powerful(状压DP)

    有n(n<10)个小球,每两个碰撞有其中一个会消失,并产生一定能量.求产生最大能量. 有了正确思路题目比较简单,我的思路果然是歪的... 我的思路是dp[i][j]表示i这个状态剩下第j个小球, ...

  4. 辗转相除法求最大公约数和最小公倍数【gcd】

    要求最小公倍数可先求出最大公约数 设要求两个数a,b的最大公约数 伪代码: int yushu,a,b: while(b不等于0) { yushu=a对b求余 b的值赋给a yushu的值赋给b } ...

  5. hdu4433 locker

    暴力dp.. dp[i][j][k] 表示 前i位完全匹配 j 表示i+1位 k表示i+2位 枚举j k #include<iostream> #include<cstdio> ...

  6. redis 操作记录

    cd opt/redis-3.2.1/ cd src ./redis-cli get token:xxx del token:xxx set token:xxx

  7. 音频播放(iOS开发)

    音频处理 一.录音 录音应用场景 语音聊天 即时通讯软件中,都包含语音发送功能 语音备忘录 录一段音频,来记录某件事情 录音功能实现 导入AVFoundation框架 作用:一些多媒体的处理,基本上都 ...

  8. POJ 3621Sightseeing Cows

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9851   Accepted: 3375 Description Farme ...

  9. 按需讲解之Supervisor

    Supervisor是一个进程监控程序. 满足的需求是:我现在有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断.当进程中断的时候我希望能自动重新启动它,此时,我就需要使用到了 ...

  10. 从CR线下活动学到的:如何组织一个小的线下活动

    作者:朱克锋 邮箱:zhukefeng@iboxpay.com 转载请注明出处:http://blog.csdn.net/linux_zkf 周末在腾讯组织了GR,活动达到了预期的收获,从这次活动我主 ...