#P9282. [AGM 2023 资格赛] 回文

[AGM 2023 资格赛] 回文

Problem Description

Define a function f(x)f(x) for a string xx as follows:

  • If xx has length 11, then f(x)=1f(x)=1.
  • If xx is not a palindrome, then f(x)=0f(x)=0.
  • If xx is a palindrome, let yy be the string consisting of the first x+12\frac{|x|+1}{2} characters of xx. Then f(x)=f(y)+1f(x)=f(y)+1.

Given a string ss and an integer kk, for every non-empty substring of ss, count how many substrings have ff equal to each value from 11 to kk.

Input Format

The first line contains two integers N(1N105)N(1\leq N\leq 10^5) and k(1k30)k(1\leq k\leq 30).

The next line contains a string ss of length NN, consisting only of lowercase letters.

Output Format

Output the answers for each value from 11 to kk.

4 3
bbab

5 1 0 

3 3
bbb

3 2 1 

Hint

Translated by ChatGPT 5