题目链接:点击打开链接
思路:
我们用d[i]表示长度为i的答案。 那么我们可以把样例数据写出来看看是否能够递推。 可以发现, d[i] = d[i-1] - last[i-1] + (n-i+1) - dist[i]。
last[i]表示从后往前i长度时不同数字的个数, 也就是说, d[i-1]的最后一个子序列被扔了, 然后d[i]比d[i-1]还可能多加了( n - i + 1)...
分类:
其他好文 时间:
2016-08-08 21:12:26
阅读次数:
180
Problem Description In this problem, you are given a string s and q queries.For each query, you should answer that when all distinct substrings of str ...
分类:
编程语言 时间:
2016-08-07 11:00:54
阅读次数:
201
题目大意:给一个长度为n的整数序列,定义egg(i,j)表示区间[i,j]中不同的数的个数。q次询问,每次询问x,表示求所有长度为x连续区间的 egg 之和。 题目分析:定义dp(len)表示所有长度为len的连续区间的egg之和。 则,dp(len)=dp(len-1)-egg(最后一个长度为le ...
分类:
其他好文 时间:
2016-07-31 19:00:25
阅读次数:
165
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 representati ...
分类:
其他好文 时间:
2016-07-31 00:01:28
阅读次数:
335
后缀数组。按照排序完的后缀一个一个统计。每一个后缀对答案做出的贡献为:n-SA[i]-height[i]。 ...
分类:
其他好文 时间:
2016-07-30 14:59:03
阅读次数:
155
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description You are given string s. Your task is to determine if the given strin ...
分类:
其他好文 时间:
2016-07-30 12:04:28
阅读次数:
210
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 representati ...
分类:
其他好文 时间:
2016-07-21 23:52:03
阅读次数:
419
http://poj.org/problem?id=1226 题意:给定n个串。求一个最长的串,使得这个串或者其反串在每个串中都出现过? 思路:先在大串里面加入正反串,然后二分,判定即可。 ...
分类:
其他好文 时间:
2016-07-03 23:23:56
阅读次数:
128
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 representati ...
分类:
其他好文 时间:
2016-06-25 17:44:12
阅读次数:
164
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 representati ...
分类:
其他好文 时间:
2016-06-04 23:47:08
阅读次数:
600