#P4590. [TJOI2018] 游园会

    ID: 3529 远端评测题 6000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>字符串递推2018各省省选枚举,暴力天津

[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 N\texttt{N}, O\texttt{O}, or I\texttt{I}. At the venue he collected a string consisting of KK 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 NN, and the substring NOI\texttt{NOI} never appears in the redemption string, i.e., there is no occurrence of NOI\texttt{NOI}. 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, N,KN, K, representing the length of the redemption string and the length of the medal string Xiaodou collected (N1000,K15N\leq1000,K\leq15).

The second line contains KK characters, representing the medal string Xiaodou obtained.

Output Format

Output K+1K+1 lines. The ii-th line is the number of different valid redemption strings for which Xiaodou’s final reward level is i1i-1. This number can be large; output the result modulo 109+710^9+7.

3 2
NO
1
19
6

Hint

Sample explanation:

Strings whose longest common subsequence length is 00: III\texttt{III}.

Strings whose longest common subsequence length is 22: NON\texttt{NON}, NNO\texttt{NNO}, NOO\texttt{NOO}, ONO\texttt{ONO}, INO\texttt{INO}, NIO\texttt{NIO}.

Excluding NOI\texttt{NOI}, the remaining 19=266119 = 26-6-1 kinds have a longest common subsequence length of 11.

Constraints

  • For 10%10\% of the testdata, N10,K10N\leq10,K\leq10.
  • For 30%30\% of the testdata, N100,K4N\leq100,K\leq4.
  • For 100%100\% of the testdata, N1000,K15N\leq1000,K\leq15.

Translated by ChatGPT 5