把T串扩展成两倍 然后KMP 注意T的长度要大于P的长度
#include#include #include #include using namespace std; char P[400005]; char T[400005]; int f[400005]; void getfail() { int m=strlen(P); f[0]=0;f[1]=0; for(int i=1;i =strlen(P))printf("yes\n"); else printf("no\n"); } return 0; }