← Home
write a go solution for F1. Kevin and Binary String (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output  This is the easy version of the problem. The difference between the versions is that in this version, string t consists of only '0' and '1'. You can hack only if you solved all versions of this problem. Kevin has a binary string s of length n. Kevin can perform the following operation:   Choose two adjacent blocks of s and swap them. A block is a maximal substring^∗ of identical characters. Formally, denote s[l,r] as the substring s_ls_l+1ldotss_r. A block is s[l,r] satisfying:   l=1 or s_lnot=s_l-1.  s_l=s_l+1=ldots=s_r.  r=n or s_rnot=s_r+1. Adjacent blocks are two blocks s[l_1,r_1] and s[l_2,r_2] satisfying r_1+1=l_2.For example, if s=mathtt000,mathbf11,mathbf00,mathtt111, Kevin can choose the two blocks s[4,5] and s[6,7] and swap them, transforming s into mathtt000,mathbf00,mathbf11,mathtt111.Given a string t of length n consisting of '0', '1' and '?', Kevin wants to determine the minimum number of operations required to perform such that for any index i (1<=i<=n), if t_inot= '?' then s_i=t_i. If it is impossible, output -1.^∗A string a is a substring of a string b if a can be obtained from b by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. InputEach test contains multiple test cases. The first line contains the number of test cases t (1<=t<=10^4). The description of the test cases follows. The first line of each test case contains a string s consisting of '0' and '1'.The second line of each test case contains a string t consisting of '0' and '1'.It is guaranteed that the lengths of s and t are the same.It is guaranteed that the sum of the length of s over all test cases will not exceed 4*10^5.OutputFor each test case, output one integer — the minimum number of operations required. If it is impossible, output -1.ExampleInput600011001110000011111010101111000010101100101101001100100111001Output1
3
1
-1
-1
-1
NoteIn the first test case, the possible way is shown in the statement.In the second test case, one possible way could be:  Swap blocks [2,2],[3,3], s will become mathtt001101.  Swap blocks [3,4],[5,5], s will become mathtt000111.  Swap blocks [1,3],[4,6], s will become mathtt111000.. Output only the code with no comments, explanation, or additional text.