luogu#P5115. Check,Check,Check one two!
Check,Check,Check one two!
Background
You are listening to くらげP’s チェチェ・チェック・ワンツー!, and suddenly the head teacher pushes the door open. So you have to pretend that you are working on a string problem.
(But the head teacher sees through this easy problem at a glance, and you get criticized for doing easy problems when you had nothing to do.)
Problem Description
You are given a string.
We define as the length of the longest common prefix of the suffix starting at position of the string and the suffix starting at position .
We define as the length of the longest common suffix of the prefix ending at position of the string and the prefix ending at position .
Now you are given a string of length , and you need to compute
$$\sum_{1\leq i < j \leq n}lcp(i,j)lcs(i,j)[lcp(i,j)\leq k1][lcs(i,j) \leq k2]$$modulo (that is, natural overflow of unsigned long long is sufficient).
means that if the proposition is true, then this term equals 1; otherwise it equals 0. The other bracket is defined similarly.
Input Format
The first line contains a string , guaranteed to consist only of lowercase English letters.
The second line contains two positive integers , representing the constraints in the statement.
Output Format
Output a single positive integer, which is the value of the given expression modulo .
aabccbbbcbbcbccacbcb
8 20
140
checkcheckcheckonetwo
7 11
216
Hint
Let denote the length of the string.
Test point 10 is worth 1 point, and for this test point, .
For all test points,
Translated by ChatGPT 5