#d11404. 子串(数据加强版)
子串(数据加强版)
Substrings (Hard Version)
Problem Description
Given a -string of length , count the number of ways to partition it so that the sequence formed by the numbers of 1s in each resulting substring is a palindrome. Output the answer modulo .
Input Format
The first line contains a positive integer , the length of the -string.
The second line contains a -string of length .
Output Format
The number of valid partition schemes, modulo .
Sample Input
3
101
Sample Output
4
Sample Explanation
The valid partitions are: . The sequences of the numbers of 1s are , all of which are palindromes.
Constraints
- Advanced: think about an solution.