#SRD0000136. Mật độ của các dãy con (Density of subarrays)
Bài tập thuộc lộ trình
Mục lục đề ⌄
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 , a -array is an array with every element in .
An array is a subsequence of array if one can select positions of in strictly increasing order to obtain . The selected positions need not be adjacent. Distinct choices of indices count separately, even if their resulting values are equal.
The density of a -array is the largest nonnegative integer such that every -array of length exactly appears as a subsequence of .
For example, with the array 1 2 1 2 has density , 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 has density .
Given a -array , consider all nonempty subsequences selected by positions. For each , count those with density exactly , modulo .
Input
- The first line contains .
- The second line contains integers .
Output
Print exactly space-separated integers , where is the number of nonempty subsequences with density exactly , modulo .
Subtasks
- Subtask 1 (10 points): ; for every .
- Subtask 2 (20 points): ; for every .
- Subtask 3 (30 points): ; for every .
- Subtask 4 (40 points): ; for every .
Examples
Example 1
Input
4 1
1 1 1 1
Output
0 4 6 4 1
Explanation
With , an array of ones has density . There are ways to choose positions among four, giving for . No nonempty subsequence has density zero.
Example 2
Input
3 3
1 2 3
Output
6 1 0 0
Explanation
There are nonempty choices of indices. Only the choice containing all three positions, 1 2 3, has every value from to 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 nonempty index choices, matching . The array at positions is 1 2 1 2 and has density two; positions form 1 2 1 with density one; positions form 1 1 1 with density zero. Density three requires at least six selected elements, more than the original length.