exhibit a from record l to the list r is the cluster [al,al+1,… ,ar]. The number of events of the exhibit b in the cluster an is the number of subarrays of a to such an extent that they are equivalent to b. You are given n exhibits A1,A2,… ,An; the components of these clusters are integers from 1 to k. You need to assemble a cluster a
C++ only. Correct answer will upvoted else downvoted.
subarray of exhibit a from record l to the list r is the cluster [al,al+1,… ,ar]. The number of events of the exhibit b in the cluster an is the number of subarrays of a to such an extent that they are equivalent to b. You are given n exhibits A1,A2,… ,An; the components of these clusters are integers from 1 to k. You need to assemble a cluster a comprising of m integers from 1 to k so that, for each given subarray
Input :The main line contains three integers n, m and k (1≤n,m,k≤3⋅105) — the number of the given clusters, the ideal length of the exhibit a, and the upper bound on the qualities in the clusters. Then, at that point, n lines follow. The I-th line addresses the exhibit Ai. The main integer in the I-th line is ci (1≤ci≤m) — the number of components in Ai; then, at that point, ci integers from 1 to k follow — the components of the exhibit Ai.
Extra imperative on the input: ∑i=1nci≤3⋅105; i. e., the number of components in the given clusters altogether doesn't surpass 3⋅105.
Output Print one integer — the number of various exhibits a you can fabricate,
Step by step
Solved in 4 steps with 1 images