#P8687. [蓝桥杯 2019 省 A] 糖果

    ID: 7689 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划,dp2019状态压缩蓝桥杯省赛

[蓝桥杯 2019 省 A] 糖果

Description

The owner of the candy shop sells a total of MM flavors of candy. For convenience, we number the MM flavors from 11 to MM.

Xiaoming wants to taste candies of all flavors. Unfortunately, the owner does not sell candies individually, but only sells them in whole packs, with KK candies per pack.

Luckily, each candy pack lists the flavors of the KK candies inside, so Xiaoming can know the flavors in a pack before buying it.

Given NN packs of candy, please compute the minimum number of packs Xiaoming needs to buy in order to taste all flavors of candy.

Input Format

The first line contains three integers NN, MM, and KK.

In the next NN lines, each line contains KK integers T1,T2,,TKT_1, T_2, \cdots , T_K, representing the flavors of one pack of candy.

Output Format

Output one integer as the answer. If Xiaoming cannot taste all flavors, output 1-1.

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

Hint

For 30%30\% of the testdata, 1N201 \le N \le 20.

For all testdata, 1N1001 \le N \le 100, 1M201 \le M \le 20, 1K201 \le K \le 20, 1TiM1 \le T_i \le M.

Lanqiao Cup 2019 Provincial Contest A Division, Problem I.

Translated by ChatGPT 5