#P1659. Harmonious Cheer Groups
Harmonious Cheer Groups
Harmonious Cheer Groups
Elliston Business School's basketball team is about to compete in the annual city basketball competition. An important highlight of the game is the cheerleading squad, which can boost morale and help the team secure a victory. As the captain of the cheerleading squad, Chu Yuxin understands how crucial it is to train a well‐coordinated group.
After a rigorous selection process, n outstanding girls have been chosen. On a sunny morning, these n girls line up from left to right, each holding a card with one lowercase English letter (from the 26 letters). A contiguous segment of these girls is called a harmonious cheer group if:
- The segment contains an odd number of girls.
- The string formed by the letters on the cards, when read from left to right, is a palindrome. In other words, it satisfies the property \( s = s^R \), where \( s^R \) denotes the reverse of \( s \).
Chu Yuxin plans to list all harmonious cheer groups and then sort them in descending order based on the number of girls in the group (i.e. the length of the segment). Let the first \( K \) groups in this sorted order have lengths \( L_1, L_2, \dots, L_K \). Your task is to compute the product
[ P = L_1 \times L_2 \times \cdots \times L_K \quad (\bmod\ 19930726), ]
and output ( P ).
Note: It is guaranteed that there will be at least \( K \) harmonious cheer groups.
inputFormat
The input consists of two lines:
- The first line contains two integers \( n \) and \( K \) (where \( 1 \leq n \leq 10^5 \)).
- The second line contains a string of length \( n \) composed of lowercase English letters.
outputFormat
Output a single integer: the product of the lengths of the first \( K \) harmonious cheer groups after sorting them in descending order, taken modulo \( 19930726 \).
sample
3 2
aaa
3