8 int fail
,flag
,next
[26];
15 inline void insert(char *s
)
17 int len
=std::strlen(s
),p
=0;
18 for (int i
=0; i
<len
; ++i
)
21 if (!ac
[p
].next
[tmp
]) ac
[p
].next
[tmp
]=++count
;
36 for (int i
=0; i
<26; i
++)
38 int p
=ac
[u
].next
[i
],tmp
;
41 for (tmp
=ac
[u
].fail
; tmp
!=-1; tmp
=ac
[tmp
].fail
)
44 ac
[p
].fail
=ac
[tmp
].next
[i
];
47 if (tmp
==-1) ac
[p
].fail
=0;
56 int p
=0,len
=std::strlen(s
),ans
=0;
57 for (int i
=0; i
<len
; i
++)
60 while (p
&& !ac
[p
].next
[tmp
]) p
=ac
[p
].fail
;
63 while (t
&& ac
[t
].flag
!=-1)
75 std::memset(ac
,0,sizeof(ac
));
76 std::memset(s
,0,sizeof(s
));
81 for (int i
=0; i
<n
; ++i
)
89 for (scanf("%c",&ch
); ch
!='\n'; scanf("%c",&ch
))
96 while (tmp
--) s
[len
++]=ch
;
113 for (int i
=0; i
<len
/2; ++i
) std::swap(s
[i
],s
[len
-i
-1]);