Under construction

Still being built. Things may change

Edit Distance

Time limit1sMemory limit512 MB

Summary
Given a binary string S, output a binary string T of the same length whose edit distance from S is more than half the length of S.
Level

Medium5 of 10

Topics
String, Greedy
Solved
No attempts yet

Problem

A binary string is a non-empty sequence of 0's and 1's, e.g., 010110010110, 11, 1110111101, etc. The edit distance of two binary strings SS and TT, denoted by edit(S,T)\text{edit}(S, T), is the minimum number of single-character edit (insert, delete, or substitute) to modify SS into TT. For example, the edit distance of 00110011 and 11001100 is 44, i.e. 0011→011→11→110→11000011 \to 011 \to 11 \to 110 \to 1100. The edit distance of 11001011100101 and 11101001110100 is 22, i.e. 1100101→1110101→11101001100101 \to 1110101 \to 1110100.

Ayu has a binary string SS. She wants to find a binary string with the same length as SS that maximizes the edit distance with SS. Formally, she wants to find a binary string Tmax⁡T_{\max} such that ∣S∣=∣Tmax⁡∣|S| = |T_{\max}| and edit(S,Tmax⁡)≥edit(S,T′)\text{edit}(S, T_{\max}) \ge \text{edit}(S, T') for all binary string T′T' satisfying ∣S∣=∣T′∣|S| = |T'|.

She needs your help! However, since she wants to make your task easier, you are allowed to return any binary string TT with the same length as SS such that the edit distance of SS and TT is more than half the length of SS. Formally, you must return a binary string TT such that ∣S∣=∣T∣|S| = |T| and edit(S,T)>∣S∣/2\text{edit}(S, T) > |S|/2.

Of course, you can still return Tmax⁡T_{\max} if you want, since it can be proven that edit(S,Tmax⁡)>∣S∣/2\text{edit}(S, T_{\max}) > |S|/2 for any binary string SS. This also proves that there exists a solution for any binary string SS. If there is more than one valid solution, you can output any of them.

Input

Input contains a binary string SS (1≤∣S∣≤20001 \le |S| \le 2000).

Output

Output in a line a binary string TT with the same length as SS that satisfies edit(S,T)>∣S∣/2\text{edit}(S, T) > |S|/2.

Examples2

  1. Example 1

    Input
    0011
    
    Expected output
    1100
    
  2. Example 2

    Input
    1100101
    
    Expected output
    0011010