#P3551. [POI 2013] USU-Take-out
[POI 2013] USU-Take-out
Description
Little Edna has received the game Take-out as a present.
Take-out is a single-player game played on a sequence of adjacent blocks, numbered from to . Each block is either white or black, and there are times as many white blocks as black blocks. The goal is to remove all blocks using permissible moves.
In a single move, you remove exactly white blocks and black block, without changing the positions of the other blocks. A move is permissible if there is no “gap” (a position of a previously removed block) between any two blocks removed in that move.
Find any sequence of permissible moves that removes all the blocks. It is guaranteed that a solution exists.
Input Format
In the first line of the standard input there are two integers, and (, ), separated by a single space, that denote the total number of blocks used in the game and the number of white blocks per black block (to be removed in every move). In all the tests the condition holds.
In the second line there is a string of letters 'b' or 'c'. These tell the colours of successive blocks (in Polish): 'b' (for biały) — white, 'c' (for czarny) — black. You may assume that in all the tests there exists a sequence of permissible moves that takes out all the blocks.
Output Format
Your program should print lines to the standard output. Successive lines should describe successive moves. Each line should contain integers, in increasing order, separated by single spaces, that denote the numbers of blocks to be removed in the move.
12 2
ccbcbbbbbbcb
1 8 12
2 6 7
3 4 5
9 10 11
Hint
Return TAT1: the same position is output times.
Return TAT2: among the output positions, the number of white blocks is not times the number of black blocks.
Return TAT3: the positions are not in increasing order, or the segment passes through a block that has already been removed.
SPJ provided by @colazcy.
Translated by ChatGPT 5
京公网安备 11011102002149号