#P3789. Colored Sequence with Weight Constraints
Colored Sequence with Weight Constraints
Colored Sequence with Weight Constraints
After the release of NEKOPARA Vol.3, Azuki, who is no longer the main character in the new work, finally gets some rest. To pass the time, she decides to color a sequence of n cells. Each cell can be painted in one of three colors: black, white, or gray. For the sake of aesthetics, she insists that no two black cells are adjacent and no two white cells are adjacent.
Azuki defines the weight of a valid sequence as the number of occurrences where a black cell and a white cell appear adjacent to each other. In other words, for every adjacent pair \( (i, i+1) \), if one cell is black and the other is white, it contributes \(1\) to the weight. For example, the sequence "gray, black, white, black" has a weight of \(2\) since there are exactly two adjacent pairs (black-white and white-black) meeting the condition.
Your task is to compute, for every \(i\) with \(0 \le i \le k\), the number of valid sequences of length \(n\) that have a weight exactly equal to \(i\). Since the answer can be very large, output each answer modulo \(998244353\). Azuki has promised you a delicious cake if you manage to solve this problem.
Note: All formulas are written in \(\LaTeX\) format.
inputFormat
The input consists of a single line containing two integers \(n\) and \(k\) \( (1 \le n, 0 \le k)\), where:
- \(n\) is the length of the sequence.
- \(k\) is the maximum weight to be queried. You need to compute the number of valid sequences for every weight \(i\) with \(0 \le i \le k\).
outputFormat
Output exactly \(k+1\) space‐separated integers. The \(i\)th integer (with \(0\)-indexing) should represent the number of valid sequences of length \(n\) with weight \(i\), taken modulo \(998244353\).
sample
1 0
3