[Solution] Mark and Lightbulbs Codeforces Solution
D. Mark and Lightbulbs
time limit per test
1.5 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputMark has just purchased a rack of lightbulbs. The state of the lightbulbs can be described with binary string , where means that the -th lightbulb is turned on, while means that the -th lightbulb is turned off.
Unfortunately, the lightbulbs are
broken, and the only operation he can perform to change the state of the lightbulbs is the following:
Unfortunately, the lightbulbs are
broken, and the only operation he can perform to change the state of the lightbulbs is the following:
- Select an index from such that .
- Toggle . Namely, if is , set to or vice versa.
👇👇👇👇👇
minimum number of operations to do so.
The first line of the input contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the number of lightbulbs.
The second line of each test case contains a binary string of length — the initial state of the lightbulbs.
The third line of each test case contains a binary string of length — the final state of the lightbulbs.
It is guaranteed that the sum of across all test cases does not exceed .
For each test case, print a line containing the minimum number of operations Mark needs to perform to transform to . If there is no such sequence of operations, print .
Input
Output
No comments:
Post a Comment