您的位置:首页 > 其它

cf#ECR 9-C - The Smallest String Concatenation-水题

2016-03-02 01:15 363 查看
http://codeforces.com/contest/632/problem/C

给n个字符串,要求拼接起来得到的串字典序最小

一开始在想怎么搞。。后来发现这个规模无脑暴力一发即可

#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

const double pi=acos(-1.0);
double eps=0.000001;
int min(int a,int b)
{
return a<b?a:b;
}
struct node
{
char s[55];
bool operator< (const node b)
{
string s1,s2;
s1=s;
s1+=b.s;
s2=b.s;
s2+=s;
if (s1<s2)
return true;
else
return false;

}
};
node tm[5*10000+50];

int main()
{
int n;
cin>>n;
int i;
for (i=1;i<=n;i++)
{
scanf("%s",tm[i].s);
}
sort(tm+1,tm+1+n);
for (i=1;i<=n;i++)
{
printf("%s",tm[i].s);
}
printf("\n");

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: