{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eYou have two strings \u003cvar\u003e\\(A \u003d A_1 A_2 ... A_n\\)\u003c/var\u003e and \u003cvar\u003e\\(B \u003d B_1 B_2 ... B_n\\)\u003c/var\u003e of the same length consisting of \u003cvar\u003e\\(0\\)\u003c/var\u003e and \u003cvar\u003e\\(1\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eYou can transform \u003cvar\u003e\\(A\\)\u003c/var\u003e using the following operations in any order and as many times as you want:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eShift \u003cvar\u003e\\(A\\)\u003c/var\u003e by one character to the left (i.e., if \u003cvar\u003e\\(A \u003d A_1 A_2 ... A_n\\)\u003c/var\u003e, replace \u003cvar\u003e\\(A\\)\u003c/var\u003e with \u003cvar\u003e\\(A_2 A_3 ... A_n A_1\\)\u003c/var\u003e).\u003c/li\u003e\r\n\u003cli\u003eShift \u003cvar\u003e\\(A\\)\u003c/var\u003e by one character to the right (i.e., if \u003cvar\u003e\\(A \u003d A_1 A_2 ... A_n\\)\u003c/var\u003e, replace \u003cvar\u003e\\(A\\)\u003c/var\u003e with \u003cvar\u003e\\(A_n A_1 A_2 ... A_{n-1}\\)\u003c/var\u003e).\u003c/li\u003e\r\n\u003cli\u003eChoose any \u003cvar\u003e\\(i\\)\u003c/var\u003e such that \u003cvar\u003e\\(B_i \u003d 1\\)\u003c/var\u003e. Flip \u003cvar\u003e\\(A_i\\)\u003c/var\u003e (i.e., set \u003cvar\u003e\\(A_i \u003d 1 - A_i\\)\u003c/var\u003e).\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eYou goal is to make strings \u003cvar\u003e\\(A\\)\u003c/var\u003e and \u003cvar\u003e\\(B\\)\u003c/var\u003e equal.\u003c/p\u003e\r\n\u003cp\u003ePrint the smallest number of operations required to achieve this, or \u003cvar\u003e\\(-1\\)\u003c/var\u003e if the goal is unreachable.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq |A| \u003d |B| \\leq 2,000\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(A\\)\u003c/var\u003e and \u003cvar\u003e\\(B\\)\u003c/var\u003e consist of \u003cvar\u003e\\(0\\)\u003c/var\u003e and \u003cvar\u003e\\(1\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(A\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(B\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint the smallest number of operations required to make strings \u003cvar\u003e\\(A\\)\u003c/var\u003e and \u003cvar\u003e\\(B\\)\u003c/var\u003e equal, or \u003cvar\u003e\\(-1\\)\u003c/var\u003e if the goal is unreachable.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1010\r\n1100\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eHere is one fastest way to achieve the goal:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eFlip \u003cvar\u003e\\(A_1\\)\u003c/var\u003e: \u003cvar\u003e\\(A \u003d 0010\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eShift \u003cvar\u003e\\(A\\)\u003c/var\u003e to the left: \u003cvar\u003e\\(A \u003d 0100\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eFlip \u003cvar\u003e\\(A_1\\)\u003c/var\u003e again: \u003cvar\u003e\\(A \u003d 1100\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThere is no way to flip the only bit in \u003cvar\u003e\\(A\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e11010\r\n10001\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eHere is one fastest way to achieve the goal:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eShift \u003cvar\u003e\\(A\\)\u003c/var\u003e to the right: \u003cvar\u003e\\(A \u003d 01101\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eFlip \u003cvar\u003e\\(A_5\\)\u003c/var\u003e: \u003cvar\u003e\\(A \u003d 01100\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eShift \u003cvar\u003e\\(A\\)\u003c/var\u003e to the left: \u003cvar\u003e\\(A \u003d 11000\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eShift \u003cvar\u003e\\(A\\)\u003c/var\u003e to the left again: \u003cvar\u003e\\(A \u003d 10001\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 4","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e0100100\r\n1111111\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eFlip \u003cvar\u003e\\(A_1\\)\u003c/var\u003e, \u003cvar\u003e\\(A_3\\)\u003c/var\u003e, \u003cvar\u003e\\(A_4\\)\u003c/var\u003e, \u003cvar\u003e\\(A_6\\)\u003c/var\u003e and \u003cvar\u003e\\(A_7\\)\u003c/var\u003e in any order.\u003c/p\u003e\u003c/section\u003e\r\n"}}]}