Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<algorithm>
- #include<vector>
- using namespace std;
- void show_vector(vector<string> s){
- for(auto i = s.begin(); i < s.end(); i++){
- cout << *i;
- }
- cout << endl;
- }
- bool comp(string s1, string s2){
- string s1s2 = s1+s2;
- string s2s1 = s2+s1;
- return (s1s2>s2s1);
- }
- int main(){
- int t; scanf("%d", &t);
- while(t--){
- int n; scanf("%d", &n);
- vector<string> a;
- for(int i = 0; i < n; i++){
- string s; cin >> s;
- a.push_back(s);
- }
- //show_vector(a);
- sort(a.begin(), a.end(), comp);
- show_vector(a);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement