#P13007. 【MX-X13-T2】「KDOI-12」不要去思考未来,把这留给未来的你。
【MX-X13-T2】「KDOI-12」不要去思考未来,把这留给未来的你。
Description
The mock contest consists of problems. Each problem has subtasks and special properties. Each subtask satisfies a subset of the special properties.
A subtask dependency means that subtask depends on subtask —that is, subtask can only be passed after subtask is passed.
Considering that the problem setters are lazy and the online judge is "not very smart," the number of subtask dependencies should be minimized. Now, you need to determine the minimum number of subtask dependencies required to ensure:
-
There does not exist a pair of subtasks such that:
- All test cases satisfying subtask must also satisfy subtask , but
- It is still possible to pass subtask without passing subtask .
-
There does not exist a pair of subtasks such that:
- There exists a test case satisfying subtask but not satisfying subtask , but
- It is impossible to pass subtask without passing subtask .
Formally, let denote the set of special properties satisfied by subtask . You need to select the smallest possible number of pairs such that:
- For any where , there exists a sequence such that for all , there exists where .
- For any where , there does not exist any sequence such that for all , there exists where .
Your task is to find the minimum number of such pairs.
Input Format
- The first line contains a positive integer , the number of problems.
- For each problem:
- The first line contains two positive integers and , the number of subtasks and special properties, respectively.
- The next lines each contain a binary string of length . The -th character of the -th string is
1if and only if the -th subtask satisfies the -th special property. - It is guaranteed that no two subtasks satisfy the exact same set of special properties.
Output Format
For each problem, output a single non-negative integer—the minimum number of subtask dependencies required.
3
4 2
00
01
10
11
5 4
1110
1100
1000
0001
0000
7 4
0101
1101
1001
0010
1110
0100
1000
4
4
7
Hint
Sample Explanation
For the second problem: Suppose the four special properties are . Then, the five subtasks correspond to the following sets:
- (empty set)
The following dependency configuration is optimal:
Data Range
| Test Case | Special Property | |
|---|---|---|
| None | ||
| A | ||
| None |
- Special Property A: Each subtask satisfies at most two special properties.
For all test cases:
- ,
- ,
- Input strings consist of
0and1, - No two subtasks share the exact same set of special properties.
Translated by DeepSeek V3.
京公网安备 11011102002149号