来源:http://codeforces.com/contest/235/problem/C
题目:给出一个串S,一个串T。S中有多少个串可以通过“处理”得到串T。
处理是指,将串分成两部分,调换顺序
CLJ出的题,这是CLJ的官方题解
This problem can be solved by many suffix structures.
I think suffix automaton is the best way to solve it because it is simple and clear.
So let us build a suffix automaton of the input string S.
And consider the query string x.
let us build a string t to be x concatenate x and drop the last char.
so every consecutive sub-string of t with length |x| is a rotation of x.
let us read string t with suffix automaton we've build, and every time take the first char out and add a new char,add the answer by the number of string equal to this current sus-btring of t(which is a rotation of x).
And one more thing,we should consider the repetend of x as well,