poj 3461 KMP
2016-10-23 14:57
232 查看
Oulipo
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 43263 | Accepted: 17413 |
3
0Source
#include <iostream> #include <cstdio> #include<limits> #include <map> #include <cstring> #include <string> #include <cstdlib> using namespace std; const int N = 1000005; char patter[10005], origin[N]; int Next[10005]; void getnext() { int i, j; int len = strlen(patter); Next[0]=-1; j=-1; i=0; while(i<len) { if(j==-1||patter[i]==patter[j]) { Next[++i]=++j; } else { j = Next[j]; } } } int kmp() { int i, j; int patterlen = strlen(patter); int originlen = strlen(origin); i = 0, j=0; int ans = 0; while(i<originlen) { if(j==-1||patter[j]==origin[i]) { i++; j++; } else j = Next[j]; if(j==patterlen) { ans++; } } return ans; } int main() { int t; scanf("%d", &t); while(t--) { scanf("%s %s", patter, origin); getnext(); printf("%d\n", kmp()); } return 0; }
相关文章推荐
- POJ 3461 kmp
- POJ 3461 Oulipo(KMP求匹配次数)
- poj 3461 Oulipo(KMP)
- POJ 3461 Oulipo(KMP)
- poj 3461 Oulipo (求匹配字符串的个数)(KMP)
- Kmp 加深理解 之 poj 3461
- Oulipo_poj_3461_KMP水题
- [poj 3461]Oulipo[kmp]
- POJ 3461 KMP
- POJ 3461 Oulipo(KMP:统计一个串出现的次数)
- POJ 3461 - Oulipo(KMP)
- POJ 3461 Oulipo(KMP统计子串出现次数)
- poj 3461 字符串单串匹配--KMP或者字符串HASH
- HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP)
- poj3461——Oulipo(kmp)
- poj 3461 Oulipo(KMP)
- poj 3461(kmp字符串匹配模板)
- poj 3461 Oulipo kmp 预处理
- POJ - 3461 Oulipo——kmp
- POJ-3461 Oulipo(KMP)