// kan mao pian 最长匹配 解决问题方法 :指针的回溯
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int N = 10010;
//加速方法 对于给定的串l 我们构造一个next数组
//对于l[t] next[t] 表示串开头有 next[t]个与l[t]前面的 next[t]个字符相同
//next[t]是所有这样的next[t]中最大的
// 更简单的说 next[len]表示长度为len的字符串 前缀与后缀相同的最大长度
int next[N];
string l;
void getNext(int next[],string l);
int KMP(string s,string l);
int main(){
return 0;
}
//next 0 0 0 0 0 0 0 0 0 1 2 3 4 0 0
// a s d f e r t y a s d f g h n
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void getNext(int next[],string l){
int j = 0,k = -1; //j 序号 k 目前匹配长度
next[0] = -1;
while(j < l.length()-1){
if(k == -1 || l[j] == l[k]){ //当l[j] == l[k]时next的定义保证了前面的l[j]个必相同 +1即可
j++;k++;
next[j] = k;
}
else k = next[k]; //
}
}
int KMP(string s,string l){
}