#K986. Minimum Team Size for Skills Coverage
Minimum Team Size for Skills Coverage
Minimum Team Size for Skills Coverage
You are given a list of team members' skills, where each member's skills are represented as a binary string. Each bit in the string represents whether the team member has a particular skill (with 1 meaning they possess the skill and 0 meaning they do not). You are also given a binary string that represents the required skills for a project. Your task is to determine the minimum number of team members needed such that the union of their skills covers all the required skills.
Formally, let \(R\) be the required skills string of length \(m\) and for each team member \(i\), let \(S_i\) be a binary string of length \(m\). You need to select a set of team members \(T\) with the minimum size such that for every index \(j\) where \(R_j = 1\), there exists at least one team member \(i \in T\) with \(S_{i,j} = 1\). If no such selection is possible, output \(-1\).
inputFormat
The input is read from stdin and consists of three lines:
- The first line contains an integer \(n\) representing the number of team members.
- The second line contains \(n\) binary strings separated by spaces, where each string represents the skills of a team member.
- The third line contains a binary string representing the required skills for the project.
outputFormat
Output a single integer to stdout which is the minimum team size required to achieve all the required skills. If it is impossible to cover all required skills, output \(-1\).
## sample3
101 110 011
111
2