1 //超时了!!!
2 #include<stdio.h>
3 #include<string.h>
4
5 char a[200001];
6 char b[100001];
7 int next[100001];
8 int A,B;
9
10 void getnext()
11 {
12 int i,j;
13 i=0;j=-1;
14 next[0]=-1;
15 while(i<B)
16 {
17 if(j==-1||b[i]==b[j])
18 next[++i]=++j;
19 else
20 j=next[j];
21 }
22 }
23
24 int kmp()
25 {
26 int i,j;
27 i=j=0;
28 getnext();
29 while(i<A)
30 {
31 if(j==-1||a[i]==b[j])
32 {
33 i++;j++;
34 }
35 else
36 j=next[j];
37 if(j==B) return 1;
38 }
39 return 0;
40 }
41
42 int main()
43 {
44 int t,i,j;
45 while(scanf("%s%s",&a,&b))
46 {
47 A=strlen(a);
48 B=strlen(b);
49 t=A<B?A:B;
50 for(i=A,j=0;j<=t;j++,i++)
51 a[i]=a[j];
52 A=A+B;
53 if(kmp())
54 printf("yes\n");
55 else
56 printf("no\n");
57 }
58 return 0;
59 }