CF1574F.Occurrences
省选/NOI-
通过率:0%
时间限制:7.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A subarray of array a from index l to the index r is the array [al,al+1,…,ar]. The number of occurrences of the array b in the array a is the number of subarrays of a such that they are equal to b.
You are given n arrays A1,A2,…,An; the elements of these arrays are integers from 1 to k. You have to build an array a consisting of m integers from 1 to k in such a way that, for every given subarray Ai, the number of occurrences of Ai in the array a is not less than the number of occurrences of each non-empty subarray of Ai in a. Note that if Ai doesn't occur in a, and no subarray of Ai occurs in a, this condition is still met for Ai.
Your task is to calculate the number of different arrays a you can build, and print it modulo 998244353.
数组 a 从下标 l 到下标 r 的子数组定义为数组 [al,al+1,…,ar]。数组 b 在数组 a 中的出现次数,是指 a 中与 b 相等的子数组的个数。
给定 n 个数组 A1,A2,…,An;这些数组的元素均为 1 到 k 之间的整数。你需要构造一个由 m 个整数(每个整数均在 1 到 k 之间)组成的数组 a,使得对每个给定的子数组 Ai,其在 a 中的出现次数不小于 Ai 的任意非空子数组在 a 中的出现次数。注意:若 Ai 在 a 中未出现,且 Ai 的所有非空子数组也均未在 a 中出现,则该条件对 Ai 依然成立。
你的任务是计算可构造的不同数组 a 的个数,并将结果对 998244353 取模后输出。
输入格式
The first line contains three integers n, m and k (1≤n,m,k≤3⋅105) — the number of the given arrays, the desired length of the array a, and the upper bound on the values in the arrays.
Then n lines follow. The i-th line represents the array Ai. The first integer in the i-th line is ci (1≤ci≤m) — the number of elements in Ai; then, ci integers from 1 to k follow — the elements of the array Ai.
Additional constraint on the input: i=1∑nci≤3⋅105; i. e., the number of elements in the given arrays in total does not exceed 3⋅105.
第一行包含三个整数 n、m 和 k(1≤n,m,k≤3⋅105),分别表示给定数组的个数、目标数组 a 的长度,以及各数组中元素值的上界。
接下来是 n 行。第 i 行表示数组 Ai。该行的第一个整数为 ci(1≤ci≤m),表示 Ai 中的元素个数;随后是 ci 个取值范围在 1 到 k 之间的整数,即数组 Ai 的元素。
输入的附加约束:i=1∑nci≤3⋅105,即所有给定数组的元素总数不超过 3⋅105。
输出格式
Print one integer — the number of different arrays a you can build, taken modulo 998244353.
输出一个整数——你可以构造的不同数组 a 的数量,对 998244353 取模。
输入输出样例
输入#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测评打分。不知道怎么写?