Poj 3461 Oulipo (KMP)
来源:互联网 发布:下载配色软件 编辑:程序博客网 时间:2024/05/16 10:19
题目链接:poj 3461
所以这是水KMP模板?
#include<cstdio>#include<cstring>#include<iostream>using namespace std;const int maxn=1000000+10;int next[maxn];char a[maxn];char b[maxn];void get_next(char *s){int l=strlen(s);int k=-1,i=0;next[0]=-1;while(i<l){if(k==-1 || s[i]==s[k]){i++; k++;if(s[i]!=s[k])next[i]=k;else next[i]=next[k];}else k=next[k];}}int find(char *x,char *y){get_next(x);int lx=strlen(x),ly=strlen(y);int i=0,j=0,tot=0;while(j<ly){if(i==-1 || x[i]==y[j]){i++; j++;if(i==lx)tot++;}else i=next[i];}return tot;}int main(){int t; scanf("%d",&t);while(t--){scanf("%s%s",a,b);printf("%d\n",find(a,b));}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)
- 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
- POJ 3461 Oulipo / KMP
- Oulipo - POJ 3461 KMP
- [HiHoCoder]#1015 : KMP算法
- 【Hibernate】Hibernate的在Eclipse+Mysql的配置、安装,纯Java,利用Annotation与HQL完成数据库的增删改查
- undefined reference to XXX
- 【spring框架】关于DataSource(上)
- cocos2dx box2d
- Poj 3461 Oulipo (KMP)
- [HiHoCoder]#1032 : 最长回文子串
- Codeforces 31E TV Game 中途相遇法 状压dp
- 2015年第三周项目四:考了语文数学的学生
- 实操 VM Player和Instant Contiki安装
- BZOJ 3670 [NOI 2014] 动物园
- 从零开始SQL注入之三
- 关于c++的测试
- 【spring框架】关于DataSource(下)