fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5.  
  6. void solve()
  7. {
  8. int n; cin >> n;
  9. string s[n];
  10. for (int i = 0; i < n; ++i)
  11. cin >> s[i];
  12. int idx[n];
  13. for (int i = 0; i < n; ++i)
  14. idx[i] = i;
  15. sort(idx, idx+n, [&](int i, int j)->bool
  16. {
  17. return s[i] + s[j] < s[j] + s[i];
  18. });
  19. for (int i = 0; i < n; ++i)
  20. cout << s[idx[i]];
  21. }
  22.  
  23. int main()
  24. {
  25. #ifndef ONLINE_JUDGE
  26. freopen("input.txt", "r", stdin);
  27. freopen("output.txt", "w", stdout);
  28. freopen("Errors.txt", "w", stderr);
  29. #endif
  30. ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  31. int t = 1;
  32. // cin >> t;
  33. while (t--)
  34. {
  35. solve();
  36. if (t) cout << '\n';
  37. }
  38. cout << '\n';
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout