COCI '20 Contest 4 #1 Pizza

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

After a long and miserable day at work, Mirko decided to order a pizza for dinner to cheer himself up. In a big pile of papers on his desk, he found a flyer of a nearby pizza restaurant. The restaurant offers m different pizzas. Pizza toppings are labeled with positive integers. i^\text{th} pizza has k_i toppings, with labels b_{i,1}, b_{i,2}, \dots, b_{i,k_i}.

Mirko is very picky when it comes to food. He doesn't like n toppings, those with labels a_1, a_2, \dots, a_n, so he wants to order a pizza that doesn't contain any of those toppings. Determine the number of pizzas that Mirko can order.

Constraints

SubtaskPointsConstraints
120n = 1
k_1 = k_2 = \dots = k_m = 1
230No additional constraints.

Input Specification

The first line contains an integer n (1 \le n \le 100), the number of toppings, followed by n distinct integers a_i (1 \le a_i \le 100), the labels of toppings Mirko dislikes.

The second line contains an integer m (1 \le m \le 100), the number of pizzas.

The following m lines describe the pizzas. The i^\text{th} line contains an integer k_i (1 \le k_i \le 100), the number of toppings, followed by k_i distinct integers b_{i,j} (1 \le b_{i,j} \le 100), the labels of toppings on the i^\text{th} pizza.

The pizzas, i.e. the sets of toppings, will be distinct.

Output Specification

Output the number of pizzas that Mirko can order.

Sample Input 1

1 2
3
1 1
1 2
1 3

Sample Output 1

2

Sample Input 2

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

Sample Output 2

2

Sample Input 3

1 4
3
1 1
1 2
1 3

Sample Output 3

3

Comments

There are no comments at the moment.