#P9282. [AGM 2023 资格赛] 回文
[AGM 2023 资格赛] 回文
Problem Description
Define a function for a string as follows:
- If has length , then .
- If is not a palindrome, then .
- If is a palindrome, let be the string consisting of the first characters of . Then .
Given a string and an integer , for every non-empty substring of , count how many substrings have equal to each value from to .
Input Format
The first line contains two integers and .
The next line contains a string of length , consisting only of lowercase letters.
Output Format
Output the answers for each value from to .
4 3
bbab
5 1 0
3 3
bbb
3 2 1
Hint
Translated by ChatGPT 5