#P8420. [THUPC 2022 决赛] 匹配
[THUPC 2022 决赛] 匹配
Problem Description
A “match item” is defined as a string of length , where each position is either or . Now there are such “match items”. We want to design a “plan”, which is also a string of length , and each position is either or .
For each “match item”, define its error value as the number of positions where the “plan” differs from the “match item”. For example, if the “match item” is and the “plan” is , then the first and third positions are different, so the error value of this “plan” for that “match item” is .
We want to find a “plan” that minimizes the sum of error values over these “match items”. In addition, there are distinct forbidden “plans”, and the “plan” we find must not be one of the forbidden “plans”.
Input Format
The first line contains three positive integers .
Then there are lines, each being a string of length . After that, there are lines, each being a string of length .
Output Format
Output one integer, the minimum possible sum of error values over the “match items” achieved by a valid “plan”.
4 1 4
0000
1000
1100
1010
1000
5
2 4 4
0000
0000
0000
1000
0100
0010
2
Hint
It is guaranteed that , , .
Translated by ChatGPT 5