This problem is in Contest(s) below:
Contest 1240:Kmp,扩展Kmp
Contest 1296:字符串入门
Contest 1053:字符串算法
Contest 1501:字符串相关算法
Contest 1139:矩阵乘法,Kmp,扩展Kmp
Contest 1498:hash