题目代号:HDU 1711 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28288 Accepted Submission(s): 11891 Problem Description Give…
Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2], ...... , a[K + M - 1]…
白书说这个是MP,没有对f 数组优化过,所以说KMP有点不准确 #include <stdio.h> int a,b; int T[1000010],P[10010];//从0开始存 int f[10010];//记录P的自我匹配 void getFail(){ int m=b; f[0]=f[1]=0; for(int i=1;i<m;i++){ int j=f[i]; while(j&&P[i]!=P[j])j=f[j]; f[i+1]= P[i]==P[j] ? j…
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Description] [题目描述] Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N…
Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 39408 Accepted Submission(s): 16269 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1],…
Number Sequence Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 90 Accepted Submission(s) : 57 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Given two sequences…
我的第一道KMP. 把两个数列分别当成KMP算法中的模式串和目标串,这道题就变成了一个KMP算法模板题. #include<stdio.h> #include<string.h> #define N 1000005 #define M 10005 int a[N],b[M]; int next[M]; int n,m; void setNext() { int i,j; i=0; j=-1; next[i]=j; while(i<m) { if(j==-1||b[i]==b[…