CF1574F.Occurrences
普及/提高-
通过率:0%
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 .
输入格式
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 .
输出格式
Print one integer — the number of different arrays a you can build, taken modulo 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