C. Dreamoon and Strings
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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

Input

The first line of the input contains the string s (1 ≤ |s| ≤ 2 000).

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

Both strings will only consist of lower case English letters.

Output

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

Sample test(s)
input
aaaaa
aa
output
2 2 1 1 0 0
input
axbaxxb
ab
output
0 1 1 2 1 1 0 0

题意:RT

思路:dp[i][j]表示s的前i个字符一共匹配了j个p串,删掉的最少字符数

            先用一个数组en[i]预处理出在s串的每一个位置i。直到能最早匹配p串的结束的位置

            转移为dp[ en[i+1] ][j+1]= min (dp[ en[i+1] ][j+1] 。dp[ i ][j] + (en[i+1]-i-m) )

Codeforces Round #272 (Div. 1)C(字符串DP)的更多相关文章

  1. Codeforces Round #272 (Div. 2) 题解

    Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...

  2. Codeforces Round #272 (Div. 1)D(字符串DP)

    D. Dreamoon and Binary time limit per test 2 seconds memory limit per test 512 megabytes input stand ...

  3. Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi dp

    B. Dreamoon and WiFi 题目连接: http://www.codeforces.com/contest/476/problem/B Description Dreamoon is s ...

  4. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings dp

    题目链接: http://www.codeforces.com/contest/476/problem/E E. Dreamoon and Strings time limit per test 1 ...

  5. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划

    E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...

  6. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  7. Codeforces Round #131 (Div. 1) B. Numbers dp

    题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...

  8. Codeforces Round #131 (Div. 2) B. Hometask dp

    题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...

  9. Codeforces Round #276 (Div. 1) D. Kindergarten dp

    D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/proble ...

随机推荐

  1. axure篇

    QQ:1187362408 欢迎技术交流和学习 axure篇(axure rp 7.0): TODO: 1.汉化组件及菜单选项 界面组件汉化: 菜单汉化: 2,了解axure 控制器中各项功能区中的菜 ...

  2. jQuery Easy UI Resizable(调整大小)组件

    Resizable(调整大小)组件,easyui基础组件之中的一个.调整大小就是能够对元素能够拖着调整大小,这个组件不依赖于其它组件,使用比較简单,相关的属性.事件都 在样例中介绍了. 演示样例: & ...

  3. UVA 10574 - Counting Rectangles(枚举+计数)

    10574 - Counting Rectangles 题目链接 题意:给定一些点,求可以成几个边平行于坐标轴的矩形 思路:先把点按x排序,再按y排序.然后用O(n^2)的方法找出每条垂直x轴的边,保 ...

  4. PYTHON学习第二天[脑图][2]

    控制流语句:if , for ,while , break , continue

  5. struts2 一个简洁的struts.xml

    struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUB ...

  6. 键盘皇者 RealForce 104Pro独家评测

    http://tech.sina.cn/?sa=t84d20738943v44&page=2&pwt=rest2&vt=4&from=mbaidu&clickt ...

  7. Android四大组件--Broadcast Receiver具体解释

    本文主要讲述了: 一.BroadcastReceiver概述: 二.BroadcastReceiver事件分类 三.BroadcastReceiver事件的编程流程 四.两类BroadcastRece ...

  8. VC实现文件拖拽OnDropFiles

    文章转自http://blog.csdn.net/zamaolangzi/article/details/5645284 使用过QQ的人都知道,只要把文件拖拽到消息框中就可以传送文件了.那么这种功能是 ...

  9. 九度OJ 1179 阶乘(模拟)

    题目1179:阶乘 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4526 解决:1315 题目描写叙述: 输入n, 求y1=1!+3!+...m!(m是小于等于n的最大奇数) y2=2! ...

  10. DataSnap起源于MIDAS(十几篇博客)

    作为MIDAS起始于Delphi3,Delphi4是MIDAS II,Delphi5中是MIDASIII,而后基于COM远程数据模块方式使用TCP/IP,HTTP,(D)COM构建出强大的通讯能力.从 ...