#P17326. [ICPC 2018 Nanjing R] Magic Potion

    ID: 16806 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>2018网络流图论建模ICPC南京

[ICPC 2018 Nanjing R] Magic Potion

题目描述

There are nn heroes and mm monsters living in an island. The monsters became very vicious these days, so the heroes decided to diminish the monsters in the island. However, the ii-th hero can only kill one monster belonging to the set MiM_i. Joe, the strategist, has kk bottles of magic potion, each of which can buff one hero's power and let him be able to kill one more monster. Since the potion is very powerful, a hero can only take at most one bottle of potion.

Please help Joe find out the maximum number of monsters that can be killed by the heroes if he uses the optimal strategy.

输入格式

The first line contains three integers n,m,kn, m, k (1≤n,m,k≤5001 \le n, m, k \le 500) —\text{---} the number of heroes, the number of monsters and the number of bottles of potion.

Each of the next nn lines contains one integer tit_i, the size of MiM_i, and the following tit_{i} integers Mi,jM_{i, j} (1≤j≤ti1 \le j \le t_i), the indices (11-based) of monsters that can be killed by the ii-th hero (1≤ti≤m,1≤Mi,j≤m1 \le t_i\le m, 1\leq M_{i, j} \le m).

输出格式

Print the maximum number of monsters that can be killed by the heroes.

3 5 2
4 1 2 3 5
2 2 5
2 1 2
4
5 10 2
2 3 10
5 1 3 4 6 10
5 3 4 6 8 9
3 1 9 10
5 1 3 6 7 10
7