Score : $900$ points
Snuke is playing with a board composed of infinitely many squares lining up in a row. Each square has an assigned integer; for each integer $i$, Square $i$ and Square $i+1$ are adjacent. Additionally, each square is painted white or black.
A string $s$ of length $n$ consisting of w
and b
represents the colors of the squares of this board, as follows:
w
, and black if that character is b
;Snuke has infinitely many white pieces and infinitely many black pieces. He will put these pieces on the board as follows:
The board initially has no piece on it.
You are given a string $t$ of length $n$ consisting of o
and _
. Find the minimum number of pieces Snuke needs to put on the board to have a piece on every square $i$ among Squares $1,..,n$ such that the $i$-th character of $t$ is o
.
It is guaranteed that $t$ has at least one occurrence of o
.
w
and b
.o
and _
.o
.Input is given from Standard Input in the following format:
$n$ $s$ $t$
Print the minimum number of pieces Snuke needs to put on the board.
3 wbb o_o
2
Let us use W
to represent a white square that needs a piece on it, B
to represent a black square that needs a piece on it, w
to represent a white square that does not need a piece on it, and b
to represent a black square that does not need a piece on it.
We have the following board:
...wwwwwwWbBbbbbb...
If we put pieces in the following order, two pieces is enough:
...wwwwwwWbBbbbbb... 2 1
Note that if we put a piece on the white square first, we will need three or more pieces:
...wwwwwwWbBbbbbb... 123
4 wwww o__o
3
If we put pieces in the following order, three pieces is enough:
...wwwwwWwwWbbbbb... 1 32
9 bbwbwbwbb _o_o_o_o_
5
If we put pieces in the following order, five pieces is enough:
...wwwwwbBwBwBwBbbbbbb... 12 3 4 5
17 wwwwbbbbbbbbwwwwb __o__o_o_ooo__oo_
11