Advertisement
Saleh127

UVA 13088

Jun 1st, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int tests;
  6. cin >> tests;
  7. while (tests--)
  8. {
  9. string s;
  10. cin >> s;
  11.  
  12. set<char>st;
  13. for (auto c : s)st.insert(c);
  14.  
  15. char c = *st.begin();
  16.  
  17. long long l = st.size(), L = s.size();
  18.  
  19. string ans;
  20.  
  21. for (int i = 0; i < L - l; i++)ans.push_back(c);
  22.  
  23. for (auto x : st)ans.push_back(x);
  24.  
  25. sort(ans.begin(), ans.end());
  26.  
  27. cout << ans << endl;
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement