Codeforces 494B Obsessive String】的更多相关文章

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),然后也有可能自…
这题的题意就很晦涩.题意是:问有多少种方法,把字符串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…
[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…
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…
[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…
题意: 给两个串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找出…
很有趣的一道题 这道题提议很难懂,其实就是让你求合法的集合数目.合法的集合定义为: 1.集合中的所有串都是s的子串,且互不重叠 2.集合中的所有串都含有子串t. 看到网上很多题解说要用kmp,但我就不用... 因为仅需进行一个字符串匹配,而hash是很好写的匹配啊 而且kmp的next指针在dp中并没有起到作用. 说一下主体思路吧: 设两个字符串为s,t,长度分别为l1,l2 首先我们在原串中查找所有的位置i,使s中以i为结尾的子串与t匹配 对于所有的位置i,标记flag[i]=1; 然后我们进…
题目链接:http://codeforces.com/problemset/problem/797/C 题意: 给你一个非空字符串s,空字符串t和u.有两种操作:(1)把s的首字符取出并添加到t的末尾.(2)把t的尾字符取出并添加到u的末尾. 问你当经过一系列操作后,s和t均为空时,字典序最小的u. 题解: 操作的本质: s为队列,t为栈. 贪心思路: (1)找到s中的最小字符c,不断出队并加入t,直至有一次出队的字符等于c,停止出队. (2)当t的尾字符小于等于s中的最小字符时,优先弹出t的尾…
Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was…
C. Minimal string 题目链接:http://codeforces.com/problemset/problem/797/C time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya recieved a gift of a string s with length up to 105 characters fo…