标签:
本以为string会耗时,就用数组,结果老是WA,没了耐心找错误,就换成string,秒过!
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <string> #include <stack> #include <cmath> #include <queue> #include <set> #include <map> typedef long long ll; using namespace std; const int inf=0x3f3f3f3f; const int maxn=1e6+10; int n; string str[55]; bool cmp(string a,string b){ string p=a+b; string q=b+a; return p>q; } int main() { while(scanf("%d",&n)!=EOF){ if(n==0)break; 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]; } cout<<endl; } return 0; }
uva 10905 Children's Game (用String的话,就是水题)
标签:
原文地址:http://www.cnblogs.com/bruce27/p/4785023.html