|POJ 3461|KMP|Oulipo
来源:互联网 发布:网络731代表什么意思 编辑:程序博客网 时间:2024/05/29 04:31
Poj传送门
纯KMP模板题,又复习了一下模板
#include<cstdio> #include<algorithm> #include<cstring> #include<vector>#define ms(i,j) memset(i,j, sizeof i);using namespace std;const int MAXL = 1000000 + 5; int T; char s1[MAXL], s2[MAXL];int f[MAXL];void getfail(){ f[0] = f[1] = 0; int len = strlen(s2); for (int i=1;i<len;i++) { int j = f[i]; while (j && s2[i]!=s2[j]) j = f[j]; f[i+1] = ((s2[i]==s2[j]) ? (j+1) : (0)); }}int kmp(){ int ret = 0; int len = strlen(s1); int m = strlen(s2); int j = 0; for (int i=0;i<len;i++) { while (j && s1[i]!=s2[j]) j = f[j]; if (s1[i]==s2[j]) j++; if (j==m) ret++; } return ret;}int main() { scanf("%d", &T); while (T--) { scanf("%s%s", s2, s1); getfail(); printf("%d\n", kmp()); } return 0; }
0 0
- poj 3461 Oulipo(KMP)
- POJ 3461 Oulipo(KMP)
- POJ 3461 Oulipo---kmp
- POJ 3461 Oulipo KMP
- poj 3461 Oulipo (KMP)
- POJ 3461 Oulipo ( KMP )
- POJ 3461 Oulipo KMP
- POJ 3461 Oulipo / KMP
- Oulipo - POJ 3461 KMP
- 【KMP】 POJ 3461 Oulipo
- KMP---POJ 3461Oulipo
- POJ 3461 Oulipo (KMP)
- poj 3461 Oulipo kmp
- 【KMP】POJ-3461 Oulipo
- KMP POJ-3461 Oulipo
- poj-3461 Oulipo 【kmp】
- POJ 3461--Oulipo【KMP】
- poj 3461 Oulipo kmp
- 如何将在Windows系统上写好的项目部署到Linux服务器上?
- PC104从出厂到开机
- java int和String 相互转换
- 173. Binary Search Tree Iterator
- Python3爬虫入门之爬取豆瓣Top250电影名称
- |POJ 3461|KMP|Oulipo
- Linux和Unix的区别
- Nginx实现反向代理负载均衡
- leetcode 376. Wiggle Subsequence
- AR/VR应用开发学习路线
- 栈
- 穷举法,实例2,啤酒和饮料
- Linux:包管理之RPM
- sublime text 插件-快捷键的使用