CodeForces 632C

题意:

n 个 串,把他们按照某个次序连起来 , 使连接后的字符串字典序最小。

做这题的时候我简直是蠢死了.....

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
const int maxn = 50010;
string str[maxn];
bool cmp(string a, string b)
{
    if((a+b) < (b+a)) return true;    
    return false ;    
}
int main() 
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>str[i];
    }
    sort(str,str+n,cmp);
    for(int i=0;i<n;i++){
        cout<<str[i];
    }
    return 0;
}
原文地址:https://www.cnblogs.com/ember/p/5703746.html