3 8 01001101 00001011 3 010 111 20 10100011011110101011 00010001111101100000
3 -1 5 The input has three independent test cases. In the first test case, initially, the sequence of the numbers of pieces in the squares is $(0, 1, 0, 0, 1, 1, 0, 1)$. By performing the operation three times as follows, you can satisfy the condition: * Choose $i = 5$. After the operation, the configuration is $(0, 0, 1, 0, 2, 0, 1, 0)$. * Choose $i = 8$. After the operation, the configuration is $(0, 0, 0, 1, 0, 2, 0, 1)$. * Choose $i = 8$. After the operation, the configuration is $(0, 0, 0, 0, 1, 0, 2, 1)$. It is impossible to satisfy the condition in fewer than three operations, so the answer is $3$. In the second test case, no matter how you perform the operations, you cannot satisfy the condition, so the answer is `-1`.
{
"problem": {
"name": "Magnets",
"description": {
"content": "You are given two length-$N$ strings $A = A_1A_2 \\ldots A_N$ and $B = B_1B_2 \\ldots B_N$, each consisting of `0` and `1`. There are $N$ squares aligned in a row from left to right. For $i = 1, 2, \\ldo",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc193_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given two length-$N$ strings $A = A_1A_2 \\ldots A_N$ and $B = B_1B_2 \\ldots B_N$, each consisting of `0` and `1`.\nThere are $N$ squares aligned in a row from left to right. For $i = 1, 2, \\ldo...",
"is_translate": false,
"language": "English"
}
]
}