pre[i]第i位数往前走多少位碰到和它相同的数
dp[i]表示长度为i的子串,dp[i]可以由dp[i-1]加上从i到n的pre[i]>i-1的数减去最后一段长度为i-1的断中的不同的数得到....
爆int+有点卡内存....
Substrings
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 3276...
分类:
编程语言 时间:
2015-08-19 00:43:47
阅读次数:
149
DISUBSTR - Distinct Substrings
no tags
Given a string, we need to find the total number of its distinct substrings.
Input
T- number of test cases. T
Each test case consists of one st...
分类:
编程语言 时间:
2015-08-18 22:48:38
阅读次数:
154
题目大意:给你N个串,求出来他们的最大公共子串的长度(子串反过来也算他们的子串)。分析:很久以前就做过这道题,当时是用的strstr做的,不过相同的都是枚举了子串......还是很暴力,希望下次遇到类似的题目我已经掌握高效的方法了。==================================...
分类:
其他好文 时间:
2015-08-15 18:15:59
阅读次数:
97
题意: 求长度大于等于K的公共子串的个数。位置不同就算不同。后缀数组求依次SA LCP, 然后就是统计答案了, 暴力统计n^2复杂度显然不可以, 我们可以利用lcp数组的"部分单调性", 用一个栈,栈中保存小于等于当前lcp的原数组的下标,两次统计, 第一次统计, 按B串统计, 把A串大于等于K的那...
分类:
编程语言 时间:
2015-08-07 22:03:51
阅读次数:
125
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1238
Substrings
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8391 Accepted Submissi...
分类:
其他好文 时间:
2015-08-07 11:09:44
阅读次数:
107
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.
Below is one possible representation of s1 = "great":
great
/ gr ...
分类:
其他好文 时间:
2015-07-25 10:44:04
阅读次数:
128
通道:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2672
分类:
其他好文 时间:
2015-07-24 17:59:06
阅读次数:
1207
题目的意思是,找到各个串的最长子串,输出长度。
我们找到最短的串,枚举这个串的所有子串,需要注意的是,这些子串的逆序也是可以的。
知道了这些,就可以写出代码了。
下面是AC的代码:
#include
#include
using namespace std;
char str[105][105];
int main()
{
char s1[105], s2[105];
int ...
分类:
其他好文 时间:
2015-07-20 23:29:19
阅读次数:
239
题目:求一个字符串中所有不同子串个数
后缀数组经典题,每一个子串一定是某个后缀的前缀,那么问题便等价于求所有后缀之间的不相同的前缀个数。我们按sa的顺序来考虑,当加入sa[k]的时候,sa[k]这个后缀的长度为n-sa[k]-1,那么便有n-sa[k]-1个前缀,但是由heigh数组可知sa[k]与sa[k-1]有height[k]个前缀是相同的,所以要除去。
注意的是这道题题意有点坑,一开始...
分类:
编程语言 时间:
2015-07-16 22:27:50
阅读次数:
136
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation...
分类:
其他好文 时间:
2015-07-16 00:36:56
阅读次数:
151