2013年4月19日

KMP算法模板

摘要: #include <iostream> #include <cstring> #include <cstdio> using namespace std; int f[1111111]; void getfail(char* P,int *f) { int m=strlen(P); f[0]=f[1]=0; for (int i=1;i<m;i++) { int j=f[i]; while (j&&P[i]!=P[j]) j=f[j]; f[i+1]=(P[i]==P[j])?j+1:0; } } ... 阅读全文

posted @ 2013-04-19 21:42 电子幼体 阅读(99) 评论(0) 推荐(0) 编辑

LA 3026 - Period KMP失配函数的应用

摘要: For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 ≤ i ≤ N) we want to know the largest K > 1 (if there is one) such that the prefix of S with lengt 阅读全文

posted @ 2013-04-19 21:41 电子幼体 阅读(183) 评论(0) 推荐(0) 编辑

LA 3942 - Remember the Word 字典树 dp

摘要: Neal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal gives it to Jiejie.Since Jiejie can't remember numbers clearly, he just uses sticks to help himself. Allowing for Jiejie' 阅读全文

posted @ 2013-04-19 19:49 电子幼体 阅读(218) 评论(0) 推荐(0) 编辑

hdu 1394 Minimum Inversion Number 线段树 逆序数

摘要: Minimum Inversion NumberTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6365Accepted Submission(s): 3875Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai 阅读全文

posted @ 2013-04-19 18:19 电子幼体 阅读(155) 评论(0) 推荐(0) 编辑

Codeforecs 69E. Subsegments STL/线段树

摘要: E. Subsegmentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputProgrammer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in, which Sasha coped with. 阅读全文

posted @ 2013-04-19 17:40 电子幼体 阅读(296) 评论(0) 推荐(0) 编辑

Codeforces 69D. Dot 博弈 dp

摘要: D. Dottime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a 阅读全文

posted @ 2013-04-19 17:37 电子幼体 阅读(304) 评论(0) 推荐(0) 编辑

导航