#C10276. Min Training Groups
Min Training Groups
Min Training Groups
You are given N employees and M topics. For each topic, you are provided with a list of employees who are knowledgeable about that topic. Your task is to determine the minimum number of employees to choose as a training group such that, for every topic, there is at least one employee in the group who knows that topic.
Formally, let \(T_i\) be the set of employees who know topic \(i\) (\(1 \leq i \leq M\)). Find the smallest integer \(k\) and a set \(S\) with \(|S| = k\) such that for every \(i\), \(S \cap T_i \neq \emptyset\).
If there are no topics or no employees, output 0.
inputFormat
The input is read from standard input and has the following format:
N M k1 a1 a2 ... ak1 k2 b1 b2 ... bk2 ... kM x1 x2 ... xkM
Here, the first line contains two integers \(N\) (the number of employees) and \(M\) (the number of topics). Each of the next \(M\) lines describes a topic. For each topic, the first integer \(k_i\) represents the count of employees who are knowledgeable in this topic, followed by \(k_i\) distinct integers representing the indices (0-indexed) of those employees.
outputFormat
Output a single integer representing the minimum number of employees needed in the training group so that every topic is covered. The output is written to standard output.
## sample6 3
2 0 1
3 0 2 3
2 1 4
2
</p>