d(i)表示从i开始的后缀即S[i, L-1]的分解方法数,字符串为S[0, L-1]则有d(i) = sum{ d(i+len(x)) | 单词x是S[i, L-1]的前缀 }递推边界为d(L) = 1,代表空串。将前n个单词构造一颗Tire树,在树中查找后缀的过程中遇到一个单词节点就代表找到一个...
分类:
其他好文 时间:
2015-04-02 01:13:10
阅读次数:
164
题意:给出n(n
思路:Trie,先把单词建成Trie,然后进行dp,dp[i]表示以字符串中第i个字母为开头的情况,然后每个状态只要在Trie树上找到相应的字母开头的单词,然后dp[i] = sum{dp[i + len(x)]}进行状态转移即可 这个x是n个单词中的一个,可以用Trie查询
code:
#include
#include
#include
using namesp...
分类:
其他好文 时间:
2015-04-01 01:55:30
阅读次数:
121
Notes:1. Dont have to allocate l1*l2, just l1+l2 is fare enough.2. remember i--, j--.3. upgrade[i+j] is += not = rec[i+j+1]/10; 1 class Solution { 2 p...
分类:
其他好文 时间:
2015-03-21 09:45:21
阅读次数:
117
Not quite hard. Just remember initialize index to 0. Because if you initialize it as -1 and all the gas satisfy the cost, it will return -1.Actually, ...
分类:
其他好文 时间:
2015-03-20 01:11:41
阅读次数:
210
There couple of edge cases need to remember:1. The result, absolute value of dividend and divisor. Otherwise, when the record goes out of boundary, th...
分类:
其他好文 时间:
2015-03-19 08:50:24
阅读次数:
125
Similar to the sorted array. But we have to remember, the position of node not depends on the index. So we need do two more things:1. Ensure the point...
分类:
其他好文 时间:
2015-03-19 06:20:30
阅读次数:
132
DescriptionFleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Z...
F -Remember the WordTime Limit:3000MSMemory Limit:0KB64bit IO Format:%lld & %lluSubmitStatusPracticeUVA 1401Appoint description:DescriptionNeal is ver...
分类:
其他好文 时间:
2015-03-12 22:13:30
阅读次数:
267
Problem DescriptionWhen I wrote down this letter, you may have been on the airplane to U.S.
We have known for 15 years, which has exceeded one-fifth of my whole life. I still remember the first time...
分类:
其他好文 时间:
2015-03-09 19:09:55
阅读次数:
168
1327. Fuses
Time limit: 1.0 second
Memory limit: 64 MB
"Janus Poluektovich (I don't remember anymore whether -A or -U) used the machine only once. He brought with him a small semitranspar...
分类:
其他好文 时间:
2015-03-09 11:01:21
阅读次数:
205