CF1204D1.Kirk and a Binary String (easy version)

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.

Kirk has a binary string ss (a string which consists of zeroes and ones) of length nn and he is asking you to find a binary string tt of the same length which satisfies the following conditions:

  • For any ll and rr ( 1lrn1 \leq l \leq r \leq n ) the length of the longest non-decreasing subsequence of the substring slsl+1srs_{l}s_{l+1} \ldots s_{r} is equal to the length of the longest non-decreasing subsequence of the substring tltl+1trt_{l}t_{l+1} \ldots t_{r} ;
  • The number of zeroes in tt is the maximum possible.

A non-decreasing subsequence of a string pp is a sequence of indices i1,i2,,iki_1, i_2, \ldots, i_k such that i1<i2<<iki_1 < i_2 < \ldots < i_k and pi1pi2pikp_{i_1} \leq p_{i_2} \leq \ldots \leq p_{i_k} . The length of the subsequence is kk .

If there are multiple substrings which satisfy the conditions, output any.

输入格式

The first line contains a binary string of length not more than 20002\: 000 .

输出格式

Output a binary string which satisfied the above conditions. If there are many such strings, output any of them.

输入输出样例

  • 输入#1

    110
    

    输出#1

    010
    
  • 输入#2

    010
    

    输出#2

    010
    
  • 输入#3

    0001111
    

    输出#3

    0000000
    
  • 输入#4

    0111001100111011101000
    

    输出#4

    0011001100001011101000
    

说明/提示

In the first example:

  • For the substrings of the length 11 the length of the longest non-decreasing subsequnce is 11 ;
  • For l=1,r=2l = 1, r = 2 the longest non-decreasing subsequnce of the substring s1s2s_{1}s_{2} is 1111 and the longest non-decreasing subsequnce of the substring t1t2t_{1}t_{2} is 0101 ;
  • For l=1,r=3l = 1, r = 3 the longest non-decreasing subsequnce of the substring s1s3s_{1}s_{3} is 1111 and the longest non-decreasing subsequnce of the substring t1t3t_{1}t_{3} is 0000 ;
  • For l=2,r=3l = 2, r = 3 the longest non-decreasing subsequnce of the substring s2s3s_{2}s_{3} is 11 and the longest non-decreasing subsequnce of the substring t2t3t_{2}t_{3} is 11 ;

The second example is similar to the first one.

首页