Berry Battle 2
문제
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 of length , consisting of characters . and b. If b, then there is a berry at position , otherwise there is no berry there. There will be exactly 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 (), and pick all the berries at positions , , , and . 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 , 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