#P14185. 回文子串划分计数
回文子串划分计数
Problem Description
Given a string that contains only lowercase letters.
Find the number of ways to partition into several non-overlapping palindromic substrings, modulo .
Below is the formal statement.
Please compute the number of ways (with no limit on the count) to choose some intervals such that the following conditions are satisfied, modulo :
- , .
- For all , .
- For all , .
- For all , the string is a palindrome (indices start from ).
Input Format
One line: the string .
Output Format
One line: the number of valid ways modulo .
abbba
5
aabcccbaa
22
abcbabcacabbcbabbcabbbcbabcbabcbcaacaaa
217952
Hint
- For of the testdata, , and contains only lowercase letters.
Translated by ChatGPT 5