2019个人训练赛第二场D - Kirk and a Binary String (easy version)题解

本文介绍了如何找到一个与给定二进制字符串长度相同的新字符串,使得新字符串中0的个数尽可能多,并且在任意子串范围内,原串与新串的最长非降子序列长度相等。通过给出的例子和代码解释了问题的解决方法。
摘要由CSDN通过智能技术生成

题目:

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 s (a string which consists of zeroes and ones) of length n and he is asking you to find a binary string t of the same length which satisfies the following conditions:

  • For any l and r (1≤l≤r≤n) the length of the longest non-decreasing subsequence of the substring slsl+1…sr is equal to the length of the longest non-decreasing subsequence of the substring tltl+1…tr;
  • The number of zeroes in t is the maximum possible.

A non-decreasing subsequence of a string p is a sequence of indices i1,i2,…,ik such that i1<i2<…<ik and pi1≤pi2≤…≤pik. T

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值