今天本来应该要写校题解报告的,但是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. C语言结构

    一个进程在内存中的布局如图所示:        .text段(正文段)——保存程序所执行的程序二进制文件,CPU执行的机器指令部分:一个程序只有一个副本:只读,防止程序由于意外事故而修改自身指令. . ...

  2. 使用Hadoop打造私有云盘之API操作

    项目介绍:使用hadoop实现云盘的增删读获取列表功能,hadoop不支持数据修改,特性是一次写入多次读取.主流的网盘也不支持该功能.今天我们用hdfs的FileSystem实现这些操作. 1.上传功 ...

  3. oracle创建表空间语句分解

    1 create tablespace db_name 2 datafile 'D:\oracle\product\10.2.0\oradata\orcl\db_name_.dbf' size 200 ...

  4. SNMP: Simple? Network Management Protocol(转)

    转自:http://www.rane.com/note161.html An SNMP Overview The Message Format The Actual Bytes Introductio ...

  5. elasticsearch安装过程中的license问题解决办法

    1.git clone git://github.com/mobz/elasticsearch-head.git 2.cd elasticsearch-head 3.npm install 出现下来问 ...

  6. 网络爬虫之Windows环境Heritrix3.0配置指南

    一.引言: 最近在忙某个商业银行的项目,需要引入外部互联网数据作为参考,作为技术选型阶段的工作,之前已经确定了中文分词工具,下一个话题就是网络爬虫的选择,目标很明确,需要下载一些财经网站的新闻信息,然 ...

  7. Oracle Linux 6.3下安装Oracle 11g R2(11.2.0.3)

    本文主要描写叙述了在Oracle Linux 6.3下安装Oracle 11gR2(11.2.0.3).从Oracle 11g開始,Oracle官方站点不再提供其Patch的下载链接,须要使用Meat ...

  8. CentOS 配置httpd使局域网能够正常訪问

    [转载请注明出处: 钱国正的专栏http://blog.csdn.net/qianguozheng/article/details/37611859] 问题: 在CentOS上安装apache,配置好 ...

  9. Android将应用log信息保存文件

    相信大家在做应用调试的时候,不可能时时通过USB线连着电脑去查看log信息,所以,将应用的log信息保存到手机本地就很有必要了,有助我们从这些log信息中提取有用的部分,以解决一些bug,下面我把网上 ...

  10. [CSS] Make element not selectable

    .noselect { -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Chrome/Safar ...