fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define Samurai ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
  4. int main(){ Samurai
  5. int _t = 1;
  6. cin >> _t;
  7. for (int i = 1; i <= _t; i++){
  8. string s; cin >> s;
  9. for(int i = 1; i<s.size(); i++){
  10. for(int j = i; j > 0; j--){
  11. if(s[j]-1 > s[j-1]){
  12. s[j]--;
  13. swap(s[j],s[j-1]);
  14. } else break;
  15. }
  16. }
  17. cout << s << '\n';
  18. }
  19. return 0;
  20. }
  21.  
  22.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout