每天一水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
|
|
|
|
付代码
- #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; / ...
随机推荐
- 教程-Delphi多线程数据库查询(ADO)
ADO多线程数据库查询通常会出现3个问题: 1.CoInitialize 没有调用(CoInitialize was not called):所以,在使用任何dbGo对象前,必须手 调用CoIniti ...
- 在Linux系统中修改IP地址
在Linux系统中,通过编辑网络配置文件,设置系统IP地址,当然要在root权限下执行,具体步骤如下: 1.切换路径到/etc/sysconfig/network-scripts [root@Comp ...
- 如何生成一副Poker
import java.util.LinkedList;import java.util.Random;//扑克类class Poker{ String color;//花色 String ...
- jQuery获取鼠标移动方向
<!doctype html> <html> <head> <meta http-equiv="Content-Type&q ...
- java初学的几个问题
1. 请问配置JDK时环境变量path和JAVA_HOME的作用是什么? 作用:告诉操作系统编译器运行的路径和生成的类路径.这样java源程序才可以进行编译和运行. 以下4-7题请在JDK环境下编译和 ...
- 过滤器Filter(2)
过滤器-编码统一处理 过滤器的写法如下 package com.gqx.encodeFilter; import java.io.IOException; import java.lang.refle ...
- Android AsyncTask运作原理和源码分析
自10年大量看源码后,很少看了,抽时间把最新的源码看看! public abstract class AsyncTask<Params, Progress, Result> { p ...
- MySQL【第一篇】安装
一.简介 MySQL 是最流行的关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司.MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言.MySQL由于其体积小. ...
- Java基础知识强化之集合框架笔记70:模拟斗地主洗牌和发牌(ArrayList)
1. 模拟斗地主洗牌和发牌 分析: A:创建一个牌盒 B:装牌 C:洗牌 D:发牌 E:看牌 2. 代码实现: package cn.itcast_03; im ...
- 集合练习——List部分
利用ArrayList 1.存储多个员工信息,包括工号,姓名,年龄,入职时间,逐条打印所有员工姓名,并输出员工个数. package CollectionPart; import java.util. ...