Jayakrishna14

CppCode

Sep 16th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  6.     int Q;
  7.     cin >> Q;
  8.     while(Q--){
  9.         int n;
  10.         cin >> n;
  11.         vector<string> input(n);
  12.         for(int i=0; i<n; i++) cin >> input[i];
  13.         auto lambda = [](string a, string b){
  14.             return a + b > b + a;
  15.         };
  16.         sort(input.begin(), input.end(), lambda);
  17.         string ans = "";
  18.         for(auto el : input) ans += el;
  19.         cout << ans << endl;
  20.     }  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment