PivotOJ

Berry Battle 2

시간 제한: 8000ms메모리 제한: 1024MB출처: NCPC 2023BOJ 30433

문제

Erik and his grandpa often go to the forest to pick blueberries. Grandpa always finds the most berries, and even though it is not a competition, Erik has had enough of this. He has observed that grandpa uses a simple greedy strategy to pick as many berries as possible. With this information, Erik will try to finally pick at least as many berries as grandpa.

The blueberry shrubs can be represented as a string s=s1s2sNs = s_1s_2 \dots s_N of length N=105N = 10^5, consisting of characters . and b. If si=s_i = b, then there is a berry at position ii, otherwise there is no berry there. There will be exactly N/2N/2 berries to start with, and they are distributed uniformly at random.

The berry picking takes place in turns. In one move, a person can choose a position ii (1iN31 \leq i \leq N-3), and pick all the berries at positions ii, i+1i+1, i+2i+2, and i+3i+3. Grandpa makes the first move, then Erik makes a move, then grandpa, and so on. Grandpa will always greedily make a move that picks as many berries as possible. Among all such moves, he will pick one uniformly at random.

You are given the string ss, and your task is to write a program that decides what moves Erik should make in order to pick at least as many berries as grandpa.

예제

예제 1

입력
20
.bbb.b.bb...b.b...bb
2

13
출력
6

17
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.