101181: [AtCoder]ABC118 B - Foods Loved by Everyone

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

Katsusando loves omelette rice.

Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.

To prove that hypothesis, he conducted a survey on $M$ kinds of foods and asked $N$ people whether they like these foods or not.

The $i$-th person answered that he/she only likes the $A_{i1}$-th, $A_{i2}$-th, $...$, $A_{iK_i}$-th food.

Find the number of the foods liked by all the $N$ people.

Constraints

  • All values in input are integers.
  • $1 \leq N, M \leq 30$
  • $1 \leq K_i \leq M$
  • $1 \leq A_{ij} \leq M$
  • For each $i$ $(1 \leq i \leq N)$, $A_{i1}, A_{i2}, ..., A_{iK_i}$ are distinct.

Constraints

Input is given from Standard Input in the following format:

$N$ $M$
$K_1$ $A_{11}$ $A_{12}$ $...$ $A_{1K_1}$
$K_2$ $A_{21}$ $A_{22}$ $...$ $A_{2K_2}$
$:$
$K_N$ $A_{N1}$ $A_{N2}$ $...$ $A_{NK_N}$

Output

Print the number of the foods liked by all the $N$ people.


Sample Input 1

3 4
2 1 3
3 1 2 3
2 3 2

Sample Output 1

1

As only the third food is liked by all the three people, $1$ should be printed.


Sample Input 2

5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4

Sample Output 2

0

Katsusando's hypothesis turned out to be wrong.


Sample Input 3

1 30
3 5 10 30

Sample Output 3

3

Input

题意翻译

### 题目简述 给定 $n$ 个数列,其中第 $i$ 个数列有 $k_i$ 个数,这个数列中的第 $j$ 个数被记为 $a_{i,j}$。每个数列中的数互不相同,且都是不大于 $m$ 的正整数。现在给出 $n,m$ 以及这 $n$ 个数列,请问,有多少个整数 $x$ 满足:$1 \le x \le m$ 且每个数列中都出现了 $x$? ### 输入格式 输入共 $(n+1)$ 行。第一行输入两个正整数 $n$ 和 $m$,中间以单个空格隔开。接下来的 $n$ 行中,第 $i$ 行(也就是全部输入中的第 $(i+1)$ 行)中会输入 $(k_i+1)$ 个数,其中第一个数是 $k_i$,接下来的 $k_i$ 个数依次为 $a_{i,1},a_{i,2},...,a_{i,k_i}$。 ### 输出格式 输出一行一个非负整数,即满足条件的 $x$ 的个数。 ### 说明/提示 **数据规模与约定** 对于全部的测试点,数据保证: - $1 \le n,m \le 30$; - 对于所有满足 $1 \le i \le n$ 且 $1 \le j \le k_i$ 的整数 $i$ 和 $j$ 来说,一定有:$1 \le k_i \le m$;$1 \le a_{i,j} \le m$;对于不同的 $j$,$a_{i,j}$ 互不相同。 - 输入数据均为整数。

加入题单

算法标签: