CF1158F.Density of subarrays

NOI/NOI+/CTSC

通过率:0%

时间限制:6.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let cc be some positive integer. Let's call an array a1,a2,…,ana_1, a_2, \ldots, a_n of positive integers cc-array, if for all ii condition 1≤ai≤c1 \leq a_i \leq c is satisfied. Let's call cc-array b1,b2,…,bkb_1, b_2, \ldots, b_k a subarray of cc-array a1,a2,…,ana_1, a_2, \ldots, a_n, if there exists such set of kk indices 1≤i1<i2<…<ik≤n1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n that bj=aijb_j = a_{i_j} for all 1≤j≤k1 \leq j \leq k. Let's define density of cc-array a1,a2,…,ana_1, a_2, \ldots, a_n as maximal non-negative integer pp, such that any cc-array, that contains pp numbers is a subarray of a1,a2,…,ana_1, a_2, \ldots, a_n.

You are given a number cc and some cc-array a1,a2,…,ana_1, a_2, \ldots, a_n. For all 0≤p≤n0 \leq p \leq n find the number of sequences of indices 1≤i1<i2<…<ik≤n1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n for all 1≤k≤n1 \leq k \leq n, such that density of array ai1,ai2,…,aika_{i_1}, a_{i_2}, \ldots, a_{i_k} is equal to pp. Find these numbers by modulo 998 244 353998\,244\,353, because they can be too large.

设 cc 为某个正整数。若一个由正整数组成的数组 a1,a2,…,ana_1, a_2, \ldots, a_n 满足对所有 ii 均有 1≤ai≤c1 \leq a_i \leq c,则称其为 cc-数组。
设 b1,b2,…,bkb_1, b_2, \ldots, b_k 是一个 cc-数组,若存在一组下标 1≤i1<i2<…<ik≤n1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n,使得对所有 1≤j≤k1 \leq j \leq k 都有 bj=aijb_j = a_{i_j},则称该 cc-数组为 cc-数组 a1,a2,…,ana_1, a_2, \ldots, a_n 的一个子序列(subarray)。
定义 cc-数组 a1,a2,…,ana_1, a_2, \ldots, a_n 的密度为最大的非负整数 pp,使得任意长度为 pp 的 cc-数组(即含 pp 个元素的 cc-数组)都是 a1,a2,…,ana_1, a_2, \ldots, a_n 的子序列。

现给定一个数 cc 和某个 cc-数组 a1,a2,…,ana_1, a_2, \ldots, a_n。对每个 0≤p≤n0 \leq p \leq n,求满足如下条件的下标序列 1≤i1<i2<…<ik≤n1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n(其中 1≤k≤n1 \leq k \leq n)的个数:子序列 ai1,ai2,…,aika_{i_1}, a_{i_2}, \ldots, a_{i_k} 的密度恰好等于 pp。
由于结果可能非常大,请对 998 244 353998\,244\,353 取模输出这些数值。

输入格式

The first line contains two integers nn and cc, separated by spaces (1≤n,c≤3 0001 \leq n, c \leq 3\,000). The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n, separated by spaces (1≤ai≤c1 \leq a_i \leq c).

第一行包含两个整数 nn 和 cc,以空格分隔(1≤n,c≤3 0001 \leq n, c \leq 3\,000)。第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n,以空格分隔(1≤ai≤c1 \leq a_i \leq c)。

输出格式

Print n+1n + 1 numbers s0,s1,…,sns_0, s_1, \ldots, s_n. sps_p should be equal to the number of sequences of indices 1≤i1<i2<…<ik≤n1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n for all 1≤k≤n1 \leq k \leq n by modulo 998 244 353998\,244\,353, such that the density of array ai1,ai2,…,aika_{i_1}, a_{i_2}, \ldots, a_{i_k} is equal to pp.

输出 n+1n + 1 个数 s0,s1,…,sns_0, s_1, \ldots, s_n。对每个 pp,sps_p 应等于满足如下条件的下标序列 1≤i1<i2<…<ik≤n1 \leq i_1 \lt i_2 \lt \ldots \lt i_k \leq n(其中 1≤k≤n1 \leq k \leq n)的个数,结果对 998 244 353998\,244\,353 取模:子数组 ai1,ai2,…,aika_{i_1}, a_{i_2}, \ldots, a_{i_k} 的密度恰好为 pp。

输入输出样例

  • 输入#1

    4 1
    1 1 1 1

    输出#1

    0 4 6 4 1
  • 输入#2

    3 3
    1 2 3

    输出#2

    6 1 0 0
  • 输入#3

    5 2
    1 2 1 2 1

    输出#3

    10 17 4 0 0 0

说明/提示

In the first example, it's easy to see that the density of array will always be equal to its length. There exists 44 sequences with one index, 66 with two indices, 44 with three and 11 with four.

In the second example, the only sequence of indices, such that the array will have non-zero density is all indices because in other cases there won't be at least one number from 11 to 33 in the array, so it won't satisfy the condition of density for p≥1p \geq 1.

在第一个例子中,很容易看出数组的密度始终等于其长度。长度为 11 的索引序列有 44 个,长度为 22 的有 66 个,长度为 33 的有 44 个,长度为 44 的有 11 个。

在第二个例子中,唯一能使数组具有非零密度的索引序列是包含全部索引的序列,因为其他情况下数组中至少缺少 11 到 33 中的一个数,从而无法满足 p≥1p \geq 1 时的密度条件。

输入解题思路,AI测评打分。不知道怎么写?

首页