next數組的應用
#include#include #include #include #include #include #include #include #define L(x) (x<<1) #define R(x) (x<<1|1) #define MID(x,y) ((x+y)>>1) #define eps 1e-8 using namespace std; #define N 1000005 int len,next[N]; char a[N]; void getfail(char *a) { int i,j; i=0;j=-1; next[0]=-1; while(i