摘要:
int a[maxn],b[maxn]; int res; void merge(int l,int r){ if(l==r)return; int mid=l+r>>1; merge(l,mid);merge(mid+1,r); int i=l,j=mid+1,p=l; while(i<=mid& 阅读全文
posted @ 2025-03-09 15:51
Marinaco
阅读(8)
评论(0)
推荐(0)
摘要:
pi数组存储着以i位置为结尾的最长匹配真前后缀的长度 模式串:s2 主串:s1 str = s2 + "#" + s1 kmp算法能够快速找到模式串在主串中的位置(当pi的大小与模式串长度一致时,说明匹配。匹配位置:i-2*m(因为还要减去模式串在str中的长度))和数量! 时间复杂度O(n) 这个 阅读全文
posted @ 2025-03-09 09:56
Marinaco
阅读(45)
评论(0)
推荐(0)
摘要:
字符串哈希重点在于将字符串映射成一个P进制数字 P通常取131 ull p[maxn],h[maxn]; const int P=131; void init(){ p[0]=1,h[0]=0; for(int i=1;i<=n;i++){ p[i]=p[i-1]*P;// p[i] -> p^i 阅读全文
posted @ 2025-03-09 09:18
Marinaco
阅读(26)
评论(0)
推荐(0)

浙公网安备 33010602011771号