BZOJ 3620 seems to have seen it in a dream. KMP + violence
Given A string, find the number of substrings in the string that meet the requirements of this substring, which can be split into ABA forms. | A |> = k, | B |> = 1
In my dream, I think every day, every day ......
N <= 15000 is obviously used directly for brute force --
Enumerate the left endpoint of the substring, and then enumerate the right endpoint
For each substring S, we need to determine whether there is a prefix and suffix match between [k, | S |-1> 1 ].
Then we can find the longest prefix Suffix of | S |-1> 1 and determine whether to exceed = k.
This is very similar to a "Botanical Garden" in NOI last year... Haha...
As a result, the constant is a little big and glorious.
# Include
# Include
# Include
# Include # define M 15010 using namespace std; int n, k, ans; int next [M]; char s [M]; void KMP (char * s) {int I, fix = 0; for (I = 2; s [I]; I ++) {while (fix & s [fix + 1]! = S [I]) fix = next [fix]; if (s [fix + 1] = s [I]) + + fix; next [I] = fix ;} fix = 0; for (I = 1; s [I]; I ++) {while (fix & s [fix + 1]! = S [I]) fix = next [fix]; if (s [fix + 1] = s [I]) ++ fix; while (fix <1> = I) fix = next [fix]; if (fix> = k) ++ ans ;}} int main () {int I; scanf ("% s", s + 1); cin> k; for (I = 0; s [I + 1]; I ++) KMP (s + I); cout <