#C10615. Minimize Adjacent Ones
Minimize Adjacent Ones
Minimize Adjacent Ones
You are given a binary string s. The task is to rearrange the characters of s such that the number of adjacent pairs of '1's is minimized while ensuring that the resulting string is the lexicographically smallest among all valid rearrangements.
One effective approach is to count the number of zeros and ones in the input. Let ( z ) be the number of zeros and ( o ) be the number of ones. Then, the optimal rearrangement is given by:
( s_{result} = 0^{z}1^{o} )
This method guarantees the minimum number of adjacent '1's and ensures the lexicographical order is the smallest.
inputFormat
The input consists of a single line containing a binary string s composed of the characters '0' and '1'.
outputFormat
Output the rearranged binary string after minimizing the number of adjacent '1's. The result should be printed as a single line.## sample
101110
001111