#P1943F. Minimum Hamming Distance
Minimum Hamming Distance
No submission language available for this problem.
Description
You are given a binary string of length .
A binary string of the same length is called good if for every (), there exist indices and such that:
- is a mode of the string
You are given another binary string of length . Find the minimum Hamming distance between and any good string .
A binary string is a string that only consists of characters and .
Character is a mode of string of length if the number of occurrences of in is at least . For example, is a mode of , is not a mode of , and both and are modes of .
The Hamming distance of strings and of length is the number of indices such that and .
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the length of the binary string .
The second line of each test case contains a binary string of length consisting of characters 0 and 1.
The third line of each test case contains a binary string of length consisting of characters 0 and 1.
It is guaranteed that the sum of over all test cases does not exceed , with the additional assurance that the sum of over all test cases does not exceed
For each test case, print the minimum Hamming distance between and any good string .
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the length of the binary string .
The second line of each test case contains a binary string of length consisting of characters 0 and 1.
The third line of each test case contains a binary string of length consisting of characters 0 and 1.
It is guaranteed that the sum of over all test cases does not exceed , with the additional assurance that the sum of over all test cases does not exceed
Output
For each test case, print the minimum Hamming distance between and any good string .
Note
In the first test case, is a good string which has Hamming distance from .
In the second test case, is a good string which has Hamming distance from . It can be proven that there are no good strings with Hamming distance less than from .
In the third test case, is a good string which has Hamming distance from .