[CF494B] Obsessive String】的更多相关文章

Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s ho…
[CF-div.1 B]Obsessive String 题目大意 两个字符串\(S,T\),求划分方案数使得一个集合中两两划分不相交且划分都包含字符串\(T\) 试题分析 kmp先求出那个位置匹配. 然后怎么办呢?显然\(f_i\)表示考虑到第i个字符的答案. 传统思想:考虑这个地方加不加. 不加:\(f_{i-1}\). 加的话分两种情况讨论,一种是加入之前的某一个集合,就是\(\sum_{j=1}^{pre_i-1} f_j\),还有就是自己创建一个集合:\(pre_{i-1}\) \(p…
[codeforces494B]Obsessive String 试题描述 Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the…
B. Obsessive String   Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following proble…
这题的题意就很晦涩.题意是:问有多少种方法,把字符串s划分成不重叠的子串(可以不使用完s的所有字符,但是这些子串必须不重叠),使得t串是所有这些新串的子串.譬如第一个样例,"ababa"和"aba",共有5种方法:{aba}(前3个),{aba}(后3个),{abab},{baba},{ababa}. 先设s的长度为lena,t的长度为lenb. 做法是:用dp[i]表示到i为止,有几种方案数,所以最终答案是dp[lena].然后考虑转移.首先dp[i]至少等于dp…
题意: 给两个串S,T,问能找出多少的S的(a1,b1)(a2,b2)..(ak,bk),使Sa1---Sb1,...Sak---Sbk都包含子串T,其中k>=1,且(a1,b1)...(ak,bk)互不相交. 比如S = "abacaba",T="aba", 当k=1时,(0,6)满足,还有其他只包含一个aba串的也满足,k-2时,(0,2)(3,6)满足,(0,2)(4,6)也满足,(0,3)(4,6)也满足,所以总共有12种. 解法:dp.先用kmp找出…
http://www.codeforces.com/problemset/problem/494/B 题意:给出两个串S,T,求有几种将S分成若干个子串,满足T都是这若干个子串的子串. 思路:f[n]代表前n个字符来划分,有多少种划分方式,sum[i]代表1到i的f的和,转移就是:对于i这个位置,可以不选,因此首先 f[i]=f[i-1],然后若是选了i,那一定至少是在有匹配位置的左边开始匹配,假设L为小于i的最右边的匹配位置,则 F[i]+=ΣF[j] (1<=j<=L-1),然后也有可能自…
很有趣的一道题 这道题提议很难懂,其实就是让你求合法的集合数目.合法的集合定义为: 1.集合中的所有串都是s的子串,且互不重叠 2.集合中的所有串都含有子串t. 看到网上很多题解说要用kmp,但我就不用... 因为仅需进行一个字符串匹配,而hash是很好写的匹配啊 而且kmp的next指针在dp中并没有起到作用. 说一下主体思路吧: 设两个字符串为s,t,长度分别为l1,l2 首先我们在原串中查找所有的位置i,使s中以i为结尾的子串与t匹配 对于所有的位置i,标记flag[i]=1; 然后我们进…
A. Treasure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s writte…
几道用到KMP的DP题: hdu 5763    hdu 3689    hdu 3336    codeforces 494B    codevs 3945 关于KMP的nx数组: 如果在本文中看见了nx[]指的是所谓“成功指针”,或者getnx()函数跟本人之前的板子写的不一样...... 都是因为求nx数组有两种方法!!! 详情请阅本人的另一篇文章:关于KMP算法的重大发现 好了我们进入正题~ 一道一道来~ hdu 5763  Another Meaning 题意及样例:原题链接 设第一个…