码迷,mamicode.com
首页 >  
搜索关键字:poj1226 substrings    ( 386个结果
HDU 4455 Substrings(预处理+dp)
题目大意:给你n个数字,然后m次查询,每次给你一个x,让你求出来1到x,2到x+1。。。不同数的和。 需要各种预处理,处理出来所有的间隔之间有多少相同的数字,处理出来最后一个被去掉的间隔有多少个不重复的数字。 dp[i] = dp[i-1]-S+T.S代表最后被略去的那个区间的不同的数,T代表新区间扩张之后每个区间增加的不同的数的和。 Substrings Time Limit: ...
分类:其他好文   时间:2014-11-29 09:01:40    阅读次数:225
leetcode : Scramble String
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...
分类:其他好文   时间:2014-11-25 23:02:09    阅读次数:229
Leetcode-Scramble String
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 representatio...
分类:其他好文   时间:2014-11-24 06:27:02    阅读次数:202
hdu 4455 Substrings(树状数组+递推)
题目链接:hdu 4455 Substrings 题目大意:给定一个长度为N的序列,现在有Q次询问,每次给定一个w,表示长度,输出序列中长度为w的连续子序列 的权值和。序列的权值表示序列中不同元素的个数。 解题思路:递推,先预处理处每个位置和前面相同的数据的最短距离P。dp[i]表示说长度为i子序列的权值和,dp[i+1] =  dp[i] + v - c。v为[i+1~N...
分类:编程语言   时间:2014-11-18 00:27:51    阅读次数:223
HDU 4455 Substrings --递推+树状数组优化
题意: 给一串数字,给q个查询,每次查询长度为w的所有子串中不同的数字个数之和为多少。解法:先预处理出D[i]为: 每个值的左边和它相等的值的位置和它的位置的距离,如果左边没有与他相同的,设为n+8(看做无穷)。考虑已知w=k的答案,推w = k+1时,这时每个区间都将增加一个数,即后n-k个数会增...
分类:编程语言   时间:2014-11-08 22:00:59    阅读次数:259
POJ 3415 Common Substrings 后缀数组+并查集
后缀数组,看到网上很多题解都是单调栈,这里提供一个不是单调栈的做法,首先将两个串 连接起来求height 求完之后按height值从大往小合并。 height值代表的是 sa[i]和sa[i-1] 的公共前缀长度,那么每次合并就是合并 i和i-1 那么在合并小的时候公共前缀更大的肯定已经都合并在一....
分类:编程语言   时间:2014-11-04 10:55:07    阅读次数:191
[Leetcode] Scramble String
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...
分类:其他好文   时间:2014-11-01 17:46:15    阅读次数:151
codeforces Round #258(div2) D解题报告
题目大意: 给出一串字符,只含有a和b。现在定义一个字串如若合并之后的字串是个回文字符串,就是一个good substrings,求出这样的字串有多少个,并输出长度为偶数和奇数的个数。 解法: 首先,我们需要注意到两个已知条件: 1. 字串可以合并,例如 abbaabbb 合并之后就是abab 2. 只有两个字符a,b 我们可以发现,合并之后的字串一定是aba或者abab类型的,那么合并之后的字串如果是回文的话,第一个字符肯定与最后一个字符相同,反之亦然。 我们可以进一步...
分类:其他好文   时间:2014-10-28 17:48:48    阅读次数:283
hdu 4455 Substrings (DP 预处理思路)
Substrings Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1727    Accepted Submission(s): 518 Problem Description XXX has an arra...
分类:其他好文   时间:2014-10-16 12:11:32    阅读次数:159
Leetcode: Scramble String
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 representatio...
分类:其他好文   时间:2014-10-05 04:01:47    阅读次数:232
386条   上一页 1 ... 33 34 35 36 37 ... 39 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!