
KMP算法
文章平均质量分 80
even_bao
这个作者很懒,什么都没留下…
展开
-
【CAIOJ 1178】 最长共同前缀长度
【题目链接】 点击打开链接【算法】 EXKMP【代码】 #include<bits/stdc++.h>using namespace std;#define MAXL 1000010int i,N,l1,l2;char s1[MAXL],s2[MAXL];int extend[MAXL],next[MAXL];...原创 2018-04-20 19:00:00 · 257 阅读 · 0 评论 -
【CAIOJ1177】 子串是否出现
【题目链接】 点击打开链接【算法】 KMP【代码】 #include<bits/stdc++.h>using namespace std;#define MAXA 1000010#define MAXB 1010int i,j,lenA,lenB;int p[MAXB];char SA[MAXA],SB[MAXB]...原创 2018-04-20 20:11:29 · 124 阅读 · 0 评论 -
【POJ 2406】 Power Strings
【题目链接】 点击打开链接【算法】 KMP 如果字符串中存在循环节,则next[len] = (循环节个数 - 1) * 循环节长度 循环节个数 = len / (len - next[len]) 【代码】 #include...原创 2018-04-21 10:08:47 · 228 阅读 · 0 评论 -
【POJ 1961】 Period
【题目链接】 点击打开链接【算法】 KMP 和POJ2406很像【代码】 #include <algorithm>#include <bitset>#include <cctype>#include <cerrno>#include <clocale>#i...原创 2018-04-21 10:39:35 · 226 阅读 · 0 评论 -
【POJ 2752】 Seek the Name, Seek the Fame
【题目链接】 点击打开链接【算法】 KMP 沿着失配指针扫一遍即可【代码】 #include <algorithm>#include <bitset>#include <cctype>#include <cerrno>#include <clocale>#in...原创 2018-04-21 10:52:58 · 119 阅读 · 0 评论 -
【POJ 3461】 Oulipo
【题目链接】 点击打开链接【算法】 KMP【代码】 #include <algorithm>#include <bitset>#include <cctype>#include <cerrno>#include <clocale>#include <cmath...原创 2018-04-21 11:41:03 · 120 阅读 · 0 评论 -
【HDU 3613】Best Reward
【题目链接】 点击打开链接【算法】 正反两遍EXKMP,即可【代码】 #include<bits/stdc++.h>using namespace std;#define MAXC 26#define MAXL 500010int T,ans,tmp,i,len;int a[MAXC+1],Next[MAXL],exte...原创 2018-04-21 17:08:08 · 325 阅读 · 0 评论