You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
517 B
C++
24 lines
517 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
string ss[1000];
|
|
int main()
|
|
{
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 0; i < n; i++)
|
|
cin >> ss[i];
|
|
sort(ss, ss + n, [](const string& l, const string& r) {
|
|
int ls = l.size(), rs = r.size();
|
|
int maxl = max(ls, rs) * 2;
|
|
for (int i = 0; i < maxl; i++)
|
|
if (l[i%ls] < r[i%rs]) return false;
|
|
else if (l[i%ls] > r[i%rs]) return true;
|
|
return true;
|
|
});
|
|
for (int i = 0; i < n; i++)
|
|
cout << ss[i];
|
|
return 0;
|
|
}
|