最近回顾了下字符串匹配 KMP 算法,相对于朴素匹配算法,KMP算法核心改进就在于:待匹配串指针 i 不发生回溯,模式串指针 j 跳转到 next[j],即变为了 j = next[j]. 由此时间复杂度由朴素匹配的 O(m*n) 降到了 O(m+n), 其中模式串长度 m, 待匹配文本串长 n.其中,比较难理解的地方就是 next 数组的求法。...
分类:
其他好文 时间:
2014-08-14 01:35:27
阅读次数:
336
#include using namespace std;struct Node{ Node *next; int data;};void createCircle(Node* &L,int n,int k){ int i = 0; Node*p = L; p ...
分类:
其他好文 时间:
2014-08-14 01:03:47
阅读次数:
216
如果选了节点u,则不能选他的父节点和子节点,每个点有一个权值,求最大权值。#include #include #include using namespace std;#define maxn 6100#define maxm 15000struct Node{ int u,v,next;}e...
分类:
其他好文 时间:
2014-08-14 00:56:37
阅读次数:
163
//len-next[len]为最小循环节的长度
# include
# include
# include
using namespace std;
int len;
char a[100010];
int next[100010];
void Getnext()
{
int i=0,j=-1;
next[0]=-1;
while(i<=len)
{
...
分类:
其他好文 时间:
2014-08-13 22:41:57
阅读次数:
450
# include
# include
# include
using namespace std;
int len;
char a[1000010];
int next[1000010];
void Getnext()
{
int i=0,j=-1;
next[0]=-1;
while(i<=len)
{
if(j==-1||a[j]==a[...
分类:
其他好文 时间:
2014-08-13 22:34:17
阅读次数:
262
poj2752 Seek the Name, Seek the Fame(next数组的运用)...
分类:
其他好文 时间:
2014-08-13 22:33:37
阅读次数:
320
# include
# include
# include
using namespace std;
char a1[1000010],a2[1000010];
int next[1000010];
int len1,len2,cot;
void Getnext()
{
int i=0,j=-1;
next[0]=-1;
while(i<=len1)
{...
分类:
其他好文 时间:
2014-08-13 22:23:07
阅读次数:
301
单链表是一种递归结构,可以将单链表看作特殊的二叉树(我把它叫做一叉树)单链表的定义:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * List...
分类:
其他好文 时间:
2014-08-13 18:37:17
阅读次数:
213
1.File ---->New ---->other ---->Web ---->Dynamic Web Project 2. Next 3. 选择添加项目 Project name : Test1234. 选择Tomcat 配置5. 选择Tomcat 配置,根据机器上的tomcat版本选择,一般....
分类:
编程语言 时间:
2014-08-13 18:25:56
阅读次数:
202
Q: I have one question about how to get the clocking data from COOIS every day , because we need to check and monitor the clocking for more accuracy ....
分类:
其他好文 时间:
2014-08-13 17:41:17
阅读次数:
210