POJ 3461 Oulipo KMP
来源:互联网 发布:网络词flop是什么意思 编辑:程序博客网 时间:2024/06/05 19:29
题意:T串在O串中有多少个?
想法:KMP
#include<iostream>#include<cstdio>#include<cstring>using namespace std;char O[1000000+50],T[10000+50];int next[10000+50],cnt;void GetNext(int len){int j=0;next[0]=next[1]=0;for(int i=1;i<len;i++){while(j>0&&T[i]!=T[j]) j=next[j];if(T[i]==T[j]) j++;next[i+1]=j;}}void KMP(int len,int mark_len){int j=0;for(int i=0;i<len;i++){while(j>0&&O[i]!=T[j]) j=next[j];if(O[i]==T[j]) j++;if(j==mark_len){cnt++;j=next[j];}}}int main(){int t;scanf("%d",&t);while(t--){memset(T,'\0',sizeof(T));memset(O,'\0',sizeof(O));scanf("%s",T);scanf("%s",O);cnt=0;GetNext(strlen(T));KMP(strlen(O),strlen(T));printf("%d\n",cnt);}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 64bit系统上安装python NLTK
- C++ hdoj 2043 密码
- JavaScript命名规范
- 程序员修炼之路0
- C语言入门-第八周:作业02
- POJ 3461 Oulipo KMP
- 再见了,CSDN
- 阅读Android官方教程 Google Training 1.7 ----- Working with System Permissions
- 系统栏系列之背景图片侵入系统栏
- jQuery-ui插件实现百度提词器的效果,各种效果可以设置
- 关于HRESULT判断的宏(SUCCEEDED/FAILED)
- 这样一类问题总是显得特殊
- 二维数组中的查找
- Retrofit2.0 OkHttp如何自动加载Cookie 持久化