每天一水SGU347
今天本来应该要写校题解报告的,但是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
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
Sample Input
sample input |
sample output |
6 |
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的更多相关文章
- Openjudge 1.13-23:区间内的真素数(每日一水)
总时间限制: 1000ms 内存限制: 65536kB 描述 找出正整数 M 和 N 之间(N 不小于 M)的所有真素数.真素数的定义:如果一个正整数 P 为素数,且其反序也为素数,那么 P 就为 ...
- poj2503--Babelfish(特里一水)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 32988 Accepted: 14189 Descr ...
- 习题10-1 UVA 11040(无聊水一水)
题意: 给你一个残缺的塔,每个数字由他下面左右两个数相加得.给你其中一部分,要求输出全部的数字. #include <iostream> #include <cstdio> # ...
- POJ 1321 棋盘问题 DFS 期末前水一水就好……
A - 棋盘问题 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- 每日一水 POJ8道水题
1. POJ 3299 Humidex 链接: http://poj.org/problem?id=3299 这道题是已知H,D,T三者的运算关系,然后告诉你其中两个.求另一个. #include&l ...
- 数论E - Biorhythms(中国剩余定理,一水)
E - Biorhythms Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Subm ...
- poj1936 假期计划第一水
All in All Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 29651 Accepted: 12312 Desc ...
- 每天一水poj1502【最短路】
#include<iostream> #include<cstdio> #include<string.h> #include<algorithm> u ...
- codeforces346 Div.2 A.Round House
课间水一水,CCF备战 package com.company.cf346; import java.io.InputStreamReader; import java.util.Scanner; / ...
随机推荐
- HDOJ-ACM1003(JAVA)
转载声明:原文转自http://www.cnblogs.com/xiezie/p/5502855.html 第一.二次的思路都是穷举: 第一次的实现是用二维数组: import java.util.* ...
- ZOJ-2362 Beloved Sons 贪心 | KM
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2362 裸的匹配问题,直接KM,就算是O(n^4)的KM也不会超. ...
- c c++ 函数入口和出口的hook(gcc 编译选项),然后打印出函数调用关系的方法
GCC Function instrumentation机制可以用来跟踪函数的调用关系,在gcc中对应的选项为“-finstrument-functions”.可查看gcc的man page来获取更详 ...
- 利用gdb 调试android jni c动态库
http://blog.dornea.nu/2015/07/01/debugging-android-native-shared-libraries/ Since I haven't done thi ...
- 【面试虐菜】—— Oracle中CHAR、VARCHAR的区别
1.CHAR. CHAR存储定长数据很方便,CHAR字段上的索引效率级高,比如定义char(10),那么不论你存储的数据是否达到了10个字节,都要占去10个字节的空间,不足的自动用空格填充,所以在读取 ...
- heX:用HTML5和Node.JS开发桌面应用
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- Install Package and Software
svn http://tortoisesvn.sourceforge.net/ git https://download.tortoisegit.org/ http://git-for-windows ...
- IOS7 自定义UIBarButtonItem 的一些问题
ios 下自定义导航栏的BarButtonItem 会产生一些偏移问题, 解决方案: 通过新建一个系统的带固定距离的Item来调节你的Item #define IOS7_NAVI_SPACE ...
- 总结swift语言常见的20个问题和回答
1.假设我是个刚入门的iOS开发人员,选swift学习呢,还是选objective-c学习,还是两个都学? 这个能够依据两种情况来决定:1.我想进入公司担任iOS开发的职位 2.我仅仅想做个独立 ...
- Android SDK Manager无法更新问题解决
有时候在网络不好的情况下,android sdk manager更新可能一直报错.原因跟国内对于google相关服务的访问受限有关系,需要设置代理访问. 最近也遇到了这个问题.解决方法如下. 启动An ...