CF1204D2.Kirk and a Binary String (hard version)
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous 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. The length of the subsequence is k.
If there are multiple substrings which satisfy the conditions, output any.
简单版本与困难版本的唯一区别在于字符串的长度。如果你解决了本题,就可以对本题进行 Hack;但只有当你同时解决了本题和上一题时,才可以对上一题进行 Hack。
Kirk 有一个长度为 n 的二进制字符串 s(即仅由 0 和 1 组成的字符串),他请你找出一个同样长度的二进制字符串 t,使其满足以下条件:
- 对任意 l 和 r(1≤l≤r≤n),子串 slsl+1…sr 的最长非递减子序列的长度,等于子串 tltl+1…tr 的最长非递减子序列的长度;
- t 中
0的个数尽可能多。
字符串 p 的一个非递减子序列是指一组下标 i1,i2,…,ik,满足 i1<i2<…<ik 且 pi1≤pi2≤…≤pik。该子序列的长度为 k。
若存在多个满足条件的字符串 t,输出任意一个即可。
输入格式
The first line contains a binary string of length not more than 105.
第一行包含一个长度不超过 105 的二进制字符串。
输出格式
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 1 the length of the longest non-decreasing subsequnce is 1;
- For l=1,r=2 the longest non-decreasing subsequnce of the substring s1s2 is 11 and the longest non-decreasing subsequnce of the substring t1t2 is 01;
- For l=1,r=3 the longest non-decreasing subsequnce of the substring s1s3 is 11 and the longest non-decreasing subsequnce of the substring t1t3 is 00;
- For l=2,r=3 the longest non-decreasing subsequnce of the substring s2s3 is 1 and the longest non-decreasing subsequnce of the substring t2t3 is 1;
The second example is similar to the first one.
在第一个例子中:
- 对于长度为 1 的子串,最长非递减子序列的长度为 1;
- 当 l=1,r=2 时,子串 s1s2 的最长非递减子序列为 11,子串 t1t2 的最长非递减子序列为 01;
- 当 l=1,r=3 时,子串 s1s3 的最长非递减子序列为 11,子串 t1t3 的最长非递减子序列为 00;
- 当 l=2,r=3 时,子串 s2s3 的最长非递减子序列为 1,子串 t2t3 的最长非递减子序列为 1;
第二个例子与第一个例子类似。
输入解题思路,AI测评打分。不知道怎么写?