fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <map>
  5. #include <algorithm>
  6. #include <string>
  7. #include <set>
  8. #include <vector>
  9. using namespace std;
  10. int main ()
  11. {
  12. int k;
  13. string s;
  14. cin >> s;
  15. cin >> k;
  16. for (int i = 1; i < 50000005; ++i)
  17. {
  18. for (int j = 1; j < s.size() && k; ++j)
  19. {
  20. if (s[j] > s[j-1])
  21. {
  22. swap(s[j], s[j-1]);
  23. --k;
  24. j = 0;
  25. }
  26. }
  27. }
  28. cout << s;
  29. return 0;
  30. }
Success #stdin #stdout 0.15s 3340KB
stdin
Standard input is empty
stdout
Standard output is empty