#P15951. [ICPC 2018 Jakarta R] Edit Distance

[ICPC 2018 Jakarta R] Edit Distance

题目描述

A binary string is a non-empty sequence of 00's and 11's, e.g., 010110010110, 11, 1110111101, etc. The edit distance of two binary strings SS and TT, denoted by edit(S,T)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. 00110111111011000011 \to 011 \to 11 \to 110 \to 1100. The edit distance of 11001011100101 and 11101001110100 is 22, i.e. 1100101111010111101001100101 \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 TmaxT_{max} such that S=Tmax|S| = |T_{max}| and edit(S,Tmax)edit(S,T)edit(S, T_{max}) \geq edit(S, T') for all binary string TT' 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)>S2edit(S, T) > \frac{|S|}{2}.

Of course, you can still return TmaxT_{max} if you want, since it can be proven that edit(S,Tmax)>S2edit(S, T_{max}) > \frac{|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 contains a binary string SS (1S20001 \leq |S| \leq 2000).

输出格式

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

0011
1100
1100101
0011010

提示

Explanation for the sample input/output #1

As illustrated in the example above, the edit distance of 00110011 and 11001100 is 44. Since 4>424 > \frac{4}{2}, 11001100 is one of the valid output for this sample.