{"problem":{"name":"Electric Board","description":{"content":"An electric bulletin board is showing a string $S$ of length $N$ consisting of `0` and `1`. You can do the following operation any number of times, where $S_i$ denotes the $i$\\-th character $(1 \\leq i","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc119_b"},"statements":[{"statement_type":"Markdown","content":"An electric bulletin board is showing a string $S$ of length $N$ consisting of `0` and `1`.\nYou can do the following operation any number of times, where $S_i$ denotes the $i$\\-th character $(1 \\leq i \\leq N)$ of the string shown in the board.\n\n> **Operation:** choose a pair of integers $(l, r)$ $(1 \\leq l < r \\leq N)$ satisfying one of the conditions below, and swap $S_l$ and $S_r$.\n> \n> *   $S_l=$ `0` and $S_{l+1}=\\cdots=S_r=$ `1`.\n> *   $S_{l}=\\cdots=S_{r-1}=$ `1` and $S_r=$ `0`.\n\nDetermine whether it is possible to make the string shown in the board match $T$, and find the minimum number of operations needed if it is possible.\n\n## Constraints\n\n*   $2 \\leq N \\leq 500000$\n*   $S$ is a string of length $N$ consisting of `0` and `1`.\n*   $T$ is a string of length $N$ consisting of `0` and `1`.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$S$\n$T$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc119_b","tags":[],"sample_group":[["7\n1110110\n1010111","2\n\nHere is one possible way to make the board show the string `1010111` in two operations:\n\n*   Do the operation with $(l, r) = (2, 4)$, changing the string in the board from `1110110` to `1011110`.\n*   Do the operation with $(l, r) = (4, 7)$, changing the string in the board from `1011110` to `1010111`."],["20\n11111000000000011111\n11111000000000011111","0\n\nThe board already shows the string $T$ before doing any operation, so the answer is $0$."],["6\n111100\n111000","\\-1\n\nIf there is no sequence of operations that makes the board show the string $T$, print `-1`."],["119\n10101111011101001011111000111111101011110011010111111111111111010111111111111110111111110111110111101111111111110111011\n11111111111111111111111111011111101011111011110111110010100101001110111011110111111111110010011111101111111101110111011","22"]],"created_at":"2026-03-03 11:01:14"}}