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
Note

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

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

题解报告:

几天后补上

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
#include <bitset>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1) using namespace std;
const int maxn = 2e3 + ;
char s[maxn],p[maxn];
int errorcode,ans[maxn]; inline void updata(int & x ,int v){x=min(x,v);} int main(int argc,char *argv[])
{
scanf("%s%s",s+,p+);
int l1 = strlen(s+),l2=strlen(p+);
int dp[l1+][l2+][l1/l2+],shang=l1/l2+;
memset(dp,0x3f,sizeof(dp));errorcode=dp[][][];dp[][][]=;memset(ans,,sizeof(ans));
for(int i = ; i < l1 ; ++ i)
for(int j = ; j < l2 ; ++ j)
for(int k = ; k <= shang ; ++ k)
if(dp[i][j][k]!=errorcode)
{
if(j==) updata(dp[i+][j][k],dp[i][j][k]);
else updata(dp[i+][j][k],dp[i][j][k]+);
if(s[i+]==p[j+])
{
if(j==l2-)
updata(dp[i+][][k+],dp[i][j][k]);
else
updata(dp[i+][j+][k],dp[i][j][k]);
}
else
{
updata(dp[i+][][k],dp[i][j][k]);
}
}
for(int j = ; j <= l2 ; ++ j)
for(int k = ; k <= shang ; ++ k)
if(dp[l1][j][k] != errorcode)
{
int v = dp[l1][j][k];
ans[v] = max(ans[v],k);
}
for(int i = ; i <= l1 ; ++ i)
if(ans[i])
{
for(int j = i + ; j <= l1 ; ++ j)
ans[j]=max(ans[j],min((l1-j)/l2,ans[i]));
}
printf("%d",ans[]);
for(int i = ; i <= l1 ; ++ i) printf(" %d",ans[i]);printf("\n");
return ;
}

Codeforces Round #272 (Div. 1) Problem C. Dreamoon and Strings的更多相关文章

  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 #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维

    & -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...

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

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

  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)AK报告

    A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #272 (Div. 1)C(字符串DP)

    C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造

    D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon like ...

  8. 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 ...

  9. Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题

    A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ...

随机推荐

  1. Wamp集成环境安装

    一.Wamp下载 点我下载WampServer2.1a-x32 二.Wamp安装步骤 三.修改语言为汉语 四.查看测试页面

  2. 一步一步教你做ios推送

    最近在研究ios的推送问题,遇到了一些问题,最终整理了一下.放在这里和大家分享 APNS的推送机制 首先我们看一下苹果官方给出的对ios推送机制的解释.如下图 Provider就是我们自己程序的后台服 ...

  3. Web服务的体系架构

    Web简介: Web是WWW(World Wide Web)的简称,又称为万维网,是建立在客户机/服务器上的,以HTML语言和HTML协议为基础,提供面向Internet服务的,有一致用户界面的一种信 ...

  4. POJ 2175 Evacuation Plan (费用流,负环,消圈法,SPFA)

    http://poj.org/problem?id=2175 Evacuation Plan Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  5. 页面传值中get和post区别

    get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应. post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到 ...

  6. WdatePicker 设置今天起 后30天可选

    <link href="{:ADDON_PUBLIC_PATH}/style/My97DatePicker/skin/WdatePicker.css" rel="s ...

  7. easyui之combobox(不定时补充)

    1,combobox的valuefeild和textfeild这两个属性,可以理解为键值对,即:键valuefeild:值textfeild textfeild是文本框内显示的值,如果要取文本框内的值 ...

  8. uva 10167 - Birthday Cake

    题解:由于解太多,随机抓 A.B, 只要有符合就行了: (首先,Ax+By=0必须表示直线,即A.B不能同时为0:另外,要注意到直线不能过输入中的2N个点:检测点在直线的哪一侧,只需要简单的线性规划的 ...

  9. [Mugeda HTML5技术教程之1] HTML5: 生存还是毁灭

    [Mugeda HTML5技术教程] 开篇: HTML5 - 生存,还是毁灭 摘要:HTML5并不试图解决所有问题.但是在很多适合的场合,HTML5是不二选择. To be, or not to be ...

  10. Backbone的RESTFUL API 解释

    RESTFUL API 从服务器获取模型:collection.fetch();//发送GET请求 地址为collection.url; 存取模型至服务器: model.save();//发送PUT请 ...