#P12395. Counting Good Interval Sequences
Counting Good Interval Sequences
Counting Good Interval Sequences
We call a sequence of n ordered pairs (intervals) \((l_i,r_i)_{i=1}^n\) over the range \([1,V]\) good if and only if:
- \(1 \le l_i \le r_i \le V\) for all \(1 \le i \le n\);
- For every \(1 \le i < j \le n\), either
\(l_j \le l_i \le r_i \le r_j\) (i.e. the later interval contains the earlier one),
or \(r_j < l_i\),
or \(r_i < l_j\) (i.e. the two intervals are disjoint).
In other words, every pair of intervals either do not intersect at all or one of them contains the other. Given two integers n
and m
, for every \(V=1,2,\dots,m\) count the number of good sequences of length n
(with each \(l_i,r_i\) chosen from \([1,V]\)) modulo \(998244353\).
Note: The answer for each \(V\) must be computed and output, separated by spaces.
inputFormat
The input consists of a single line containing two space‐separated integers n
and m
.
outputFormat
Output m
space‐separated integers. The i-th integer should be the number of good sequences of length n
with value range \(V=i\) modulo \(998244353\).
sample
1 3
1 3 6