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. ith pizza has ki toppings, with labels bi,1,bi,2,,bi,ki.

Mirko is very picky when it comes to food. He doesn't like n toppings, those with labels a1,a2,,an, 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
k1=k2==km=1
230No additional constraints.

Input Specification

The first line contains an integer n (1n100), the number of toppings, followed by n distinct integers ai (1ai100), the labels of toppings Mirko dislikes.

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

The following m lines describe the pizzas. The ith line contains an integer ki (1ki100), the number of toppings, followed by ki distinct integers bi,j (1bi,j100), the labels of toppings on the ith 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

Copy
1 2
3
1 1
1 2
1 3

Sample Output 1

Copy
2

Sample Input 2

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

Sample Output 2

Copy
2

Sample Input 3

Copy
1 4
3
1 1
1 2
1 3

Sample Output 3

Copy
3

Comments

There are no comments at the moment.