CF1574F.Occurrences

省选/NOI-

通过率:0%

时间限制:7.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

A subarray of array aa from index ll to the index rr is the array [al,al+1,…,ar][a_l, a_{l+1}, \dots, a_{r}]. The number of occurrences of the array bb in the array aa is the number of subarrays of aa such that they are equal to bb.

You are given nn arrays A1,A2,…,AnA_1, A_2, \dots, A_n; the elements of these arrays are integers from 11 to kk. You have to build an array aa consisting of mm integers from 11 to kk in such a way that, for every given subarray AiA_i, the number of occurrences of AiA_i in the array aa is not less than the number of occurrences of each non-empty subarray of AiA_i in aa. Note that if AiA_i doesn't occur in aa, and no subarray of AiA_i occurs in aa, this condition is still met for AiA_i.

Your task is to calculate the number of different arrays aa you can build, and print it modulo 998244353998244353.

数组 aa 从下标 ll 到下标 rr 的子数组定义为数组 [al,al+1,…,ar][a_l, a_{l+1}, \dots, a_{r}]。数组 bb 在数组 aa 中的出现次数,是指 aa 中与 bb 相等的子数组的个数。

给定 nn 个数组 A1,A2,…,AnA_1, A_2, \dots, A_n;这些数组的元素均为 11 到 kk 之间的整数。你需要构造一个由 mm 个整数(每个整数均在 11 到 kk 之间)组成的数组 aa,使得对每个给定的子数组 AiA_i,其在 aa 中的出现次数不小于 AiA_i 的任意非空子数组在 aa 中的出现次数。注意:若 AiA_i 在 aa 中未出现,且 AiA_i 的所有非空子数组也均未在 aa 中出现,则该条件对 AiA_i 依然成立。

你的任务是计算可构造的不同数组 aa 的个数,并将结果对 998244353998244353 取模后输出。

输入格式

The first line contains three integers nn, mm and kk (1≤n,m,k≤3⋅1051 \le n, m, k \le 3 \cdot 10^5) — the number of the given arrays, the desired length of the array aa, and the upper bound on the values in the arrays.

Then nn lines follow. The ii-th line represents the array AiA_i. The first integer in the ii-th line is cic_i (1≤ci≤m1 \le c_i \le m) — the number of elements in AiA_i; then, cic_i integers from 11 to kk follow — the elements of the array AiA_i.

Additional constraint on the input: ∑i=1nci≤3⋅105\sum\limits_{i=1}^n c_i \le 3 \cdot 10^5; i. e., the number of elements in the given arrays in total does not exceed 3⋅1053 \cdot 10^5.

第一行包含三个整数 nn、mm 和 kk(1≤n,m,k≤3⋅1051 \le n, m, k \le 3 \cdot 10^5),分别表示给定数组的个数、目标数组 aa 的长度,以及各数组中元素值的上界。

接下来是 nn 行。第 ii 行表示数组 AiA_i。该行的第一个整数为 cic_i(1≤ci≤m1 \le c_i \le m),表示 AiA_i 中的元素个数;随后是 cic_i 个取值范围在 11 到 kk 之间的整数,即数组 AiA_i 的元素。

输入的附加约束:∑i=1nci≤3⋅105\sum\limits_{i=1}^n c_i \le 3 \cdot 10^5,即所有给定数组的元素总数不超过 3⋅1053 \cdot 10^5。

输出格式

Print one integer — the number of different arrays aa you can build, taken modulo 998244353998244353.

输出一个整数——你可以构造的不同数组 aa 的数量,对 998244353998244353 取模。

输入输出样例

  • 输入#1

    2 4 3
    2 1 2
    1 3

    输出#1

    5
  • 输入#2

    2 4 3
    2 1 2
    3 3 2 1

    输出#2

    0
  • 输入#3

    1 42 1337
    2 13 31

    输出#3

    721234447

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

首页