Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- string s;
- cin >> s;
- string ans;
- int f=0;
- if (s[0]=='2') f=1;
- for (int i=1; i<s.size(); i++) {
- if (s[i]=='2') f=1;
- if (f && s[i]=='0') {
- string x=s.substr(0, i);
- s=s.substr(i);
- sort(x.begin(), x.end());
- ans += x;
- f=0;
- i=0;
- }
- if (i==s.size()-1) {
- sort(s.begin(), s.end());
- ans += s;
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment