lina_os

Untitled

Apr 5th, 2025
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. string s;
  9. cin >> s;
  10. string ans;
  11. int f=0;
  12. if (s[0]=='2') f=1;
  13. for (int i=1; i<s.size(); i++) {
  14. if (s[i]=='2') f=1;
  15. if (f && s[i]=='0') {
  16. string x=s.substr(0, i);
  17. s=s.substr(i);
  18. sort(x.begin(), x.end());
  19. ans += x;
  20. f=0;
  21. i=0;
  22. }
  23. if (i==s.size()-1) {
  24. sort(s.begin(), s.end());
  25. ans += s;
  26. }
  27. }
  28. cout << ans << endl;
  29. return 0;
  30.  
  31. }
  32.  
  33.  
Advertisement
Add Comment
Please, Sign In to add comment