GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 15 July 2022

[Solution] Mark and Lightbulbs Codeforces Solution



D. Mark and Lightbulbs
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Mark has just purchased a rack of n lightbulbs. The state of the lightbulbs can be described with binary string s=s1s2sn, where si=1 means that the i-th lightbulb is turned on, while si=0 means that the i-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:
  • Select an index i from 2,3,,n1 such that si1si+1.
  • Toggle si. Namely, if si is 0, set si to 1 or vice versa.
Mark wants the state of the lightbulbs to be another binary string t. Help Mark determine the
Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇
 minimum number of operations to do so.

The first line of the input contains a single integer q (1q104) — the number of test cases.
The first line of each test case contains a single integer n (3n2105) — the number of lightbulbs.
The second line of each test case contains a binary string s of length n — the initial state of the lightbulbs.
The third line of each test case contains a binary string t of length n — the final state of the lightbulbs.
It is guaranteed that the sum of n across all test cases does not exceed 2105.
For each test case, print a line containing the minimum number of operations Mark needs to perform to transform s to t. If there is no such sequence of operations, print 1.
Input
Output

No comments:

Post a Comment