PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SRD0000136. Mật độ của các dãy con (Density of subarrays)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Mật độ của các dãy con (Density of subarrays)

Density of subarrays

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

For a positive integer cc, a cc-array is an array with every element in {1,2,…,c}\{1,2,\ldots,c\}.

An array BB is a subsequence of array AA if one can select positions of AA in strictly increasing order to obtain BB. The selected positions need not be adjacent. Distinct choices of indices count separately, even if their resulting values are equal.

The density of a cc-array BB is the largest nonnegative integer pp such that every cc-array of length exactly pp appears as a subsequence of BB.

For example, with c=2c=2 the array 1 2 1 2 has density 22, since all four length-two arrays (1 1, 1 2, 2 1, 2 2) appear as subsequences, but not every length-three array does. An array that omits any value from {1,…,c}\{1,\ldots,c\} has density 00.

Given a cc-array a1,a2,…,ana_1,a_2,\ldots,a_n, consider all nonempty subsequences selected by positions. For each p=0,1,…,np=0,1,\ldots,n, count those with density exactly pp, modulo 998244353998244353.

Input

  • The first line contains n,cn,c.
  • The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print exactly n+1n+1 space-separated integers s0,s1,…,sns_0,s_1,\ldots,s_n, where sps_p is the number of nonempty subsequences with density exactly pp, modulo 998244353998244353.

Subtasks

  • Subtask 1 (10 points): 1≤n,c≤151\le n,c\le15; 1≤ai≤c1\le a_i\le c for every 1≤i≤n1\le i\le n.
  • Subtask 2 (20 points): 1≤n,c≤1001\le n,c\le100; 1≤ai≤c1\le a_i\le c for every 1≤i≤n1\le i\le n.
  • Subtask 3 (30 points): 1≤n,c≤8001\le n,c\le800; 1≤ai≤c1\le a_i\le c for every 1≤i≤n1\le i\le n.
  • Subtask 4 (40 points): 1≤n,c≤3 0001\le n,c\le3\,000; 1≤ai≤c1\le a_i\le c for every 1≤i≤n1\le i\le n.

Examples

Example 1

Input

4 1
1 1 1 1

Output

0 4 6 4 1

Explanation

With c=1c=1, an array of tt ones has density tt. There are (4t)\binom{4}{t} ways to choose tt positions among four, giving 4,6,4,14,6,4,1 for t=1,2,3,4t=1,2,3,4. No nonempty subsequence has density zero.

Example 2

Input

3 3
1 2 3

Output

6 1 0 0

Explanation

There are 23−1=72^3-1=7 nonempty choices of indices. Only the choice containing all three positions, 1 2 3, has every value from 11 to 33 and density one. The remaining six subsequences omit at least one value and have density zero. No subsequence has enough elements for density two.

Example 3

Input

5 2
1 2 1 2 1

Output

10 17 4 0 0 0

Explanation

There are 25−1=312^5-1=31 nonempty index choices, matching 10+17+4=3110+17+4=31. The array at positions (1,2,3,4)(1,2,3,4) is 1 2 1 2 and has density two; positions (1,2,3)(1,2,3) form 1 2 1 with density one; positions (1,3,5)(1,3,5) form 1 1 1 with density zero. Density three requires at least six selected elements, more than the original length.