AtCoder Grand Contest 030
E
Less than 3
AtCoder
⌀ 3753
原题
← DF →
翻译中…

Problem Statement

翻译中…

You are given strings $s$ and $t$, both of length $N$. $s$ and $t$ consist of 0 and 1. Additionally, in these strings, the same character never occurs three or more times in a row.

翻译中…

You can modify $s$ by repeatedly performing the following operation:

翻译中…
  • Choose an index $i$ ($1 \leq i \leq N$) freely and invert the $i$-th character in $s$ (that is, replace 0 with 1, and 1 with 0), under the condition that the same character would not occur three or more times in a row in $s$ after the operation.
翻译中…

Your objective is to make $s$ equal to $t$. Find the minimum number of operations required.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 5000$
  • The lengths of $s$ and $t$ are both $N$.
  • $s$ and $t$ consists of 0 and 1.
  • In $s$ and $t$, the same character never occurs three or more times in a row.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
s
t

翻译中…

Output

翻译中…

Find the minimum number of operations required to make $s$ equal to $t$. It can be proved that the objective is always achievable in a finite number of operations.

翻译中…

样例

Input #1
4
0011
0101
Output #1
4
One possible solution is `0011` → `1011` → `1001` → `1101` → `0101`.
Input #2
1
0
0
Output #2
0
Input #3
8
00110011
10101010
Output #3
10
题目信息
题号
agc030_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。