#P4590. [TJOI2018] 游园会
[TJOI2018] 游园会
Description
Xiaodou participated in the NOI funfair. At the venue, each time he completes an activity he receives a medal, and each medal is labeled only with , , or . At the venue he collected a string consisting of medals. The redemption rule is that the length of the longest common subsequence between the medal string and a redemption string is Xiaodou’s final reward level. It is known that the redemption string has length , and the substring never appears in the redemption string, i.e., there is no occurrence of . Now Xiaodou wants to know, for each reward level, how many different valid redemption strings correspond to it.
Input Format
The first line contains two integers, , representing the length of the redemption string and the length of the medal string Xiaodou collected ().
The second line contains characters, representing the medal string Xiaodou obtained.
Output Format
Output lines. The -th line is the number of different valid redemption strings for which Xiaodou’s final reward level is . This number can be large; output the result modulo .
3 2
NO
1
19
6
Hint
Sample explanation:
Strings whose longest common subsequence length is : .
Strings whose longest common subsequence length is : , , , , , .
Excluding , the remaining kinds have a longest common subsequence length of .
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号