#P4891. Dreamoon and Strings

Dreamoon and Strings

Dreamoon and Strings

题面翻译

题目描述:

Dreamoon 有一个字符串 ss 和一个模式串 pp,他会先从 ss 中删除恰好 xx 个字符来产生一个新的字符串 ss'。然后他会计算 occ(s,p)occ(s',p),即从 ss' 中能找到的等于 pp 的不相交的子串数量的最大值。他想让 occ(s,p)occ(s',p) 的值尽可能大。

更形式地说,让我们用 ans(x)ans(x) 表示所有可以从 ss 中删去恰好 xx 个字符得到的 ss'occ(s,p)occ(s',p) 的最大值。Dreamoon 想要知道对于所有的 xx (0xs)(0 \leq x \leq |s|)ans(x)ans(x) 的值。

输入格式:

第一、二行分别输入一个字符串:sspp(1s2000,1p500)(1 \leq |s| \leq 2000,1 \leq |p| \leq 500),两串只包含小写英文字母。

输出格式:

一行,(s+1)(|s|+1) 个数,分别代表 ans(0),ans(1),,ans(s)ans(0),ans(1),\dots,ans(|s|)

题目描述

Dreamoon has a string s s and a pattern string p p . He first removes exactly x x characters from s s obtaining string s s' as a result. Then he calculates that is defined as the maximal number of non-overlapping substrings equal to p p that can be found in s s' . He wants to make this number as big as possible.

More formally, let's define as maximum value of over all s s' that can be obtained by removing exactly x x characters from s s . Dreamoon wants to know for all x x from 0 0 to s |s| where s |s| denotes the length of string s s .

输入格式

The first line of the input contains the string s s ( 1<=s<=2000 1<=|s|<=2000 ).

The second line of the input contains the string p p ( 1<=p<=500 1<=|p|<=500 ).

Both strings will only consist of lower case English letters.

输出格式

Print s+1 |s|+1 space-separated integers in a single line representing the for all x x from 0 0 to s |s| .

样例 #1

样例输入 #1

aaaaa
aa

样例输出 #1

2 2 1 1 0 0

样例 #2

样例输入 #2

axbaxxb
ab

样例输出 #2

0 1 1 2 1 1 0 0

提示

For the first sample, the corresponding optimal values of s s' after removal 0 0 through s=5 |s|=5 characters from s s are {"aaaaa", "aaaa", "aaa", "aa", "a", ""}.

For the second sample, possible corresponding optimal values of s s' are {"axbaxxb", "abaxxb", "axbab", "abab", "aba", "ab", "a", ""}.