來源: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,