#HK5007. 「POI2013 R1」消除游戏 Take-out

「POI2013 R1」消除游戏 Take-out

题目描述

题目译自 XX Olimpiada Informatyczna — I etap Usuwanka

小 Bajtosia 收到了一款名为「消除游戏」的礼物。游戏中有一串 nn 个紧邻的积木,编号从 11nn,每块积木为白色或黑色,白色积木数量是黑色积木的 kk 倍。这款单人游戏的目标是通过特定操作,移除所有积木。

每次操作需移除恰好 kk 个白色积木和 11 个黑色积木,且不改变其余积木位置。操作需满足条件:移除的积木之间无空隙,即无先前移除积木留下的空白。

Bajtosia 恳求你的帮助!请为她找出一组合法操作序列,移除所有积木。

输入格式

第一行包含两个整数 n,kn, k (2n1000000,1kn1)(2 \leq n \leq 1000000, 1 \leq k \leq n-1),分别表示积木总数和每次操作需移除的白色积木数。保证 k+1nk+1 \mid n

第二行包含一个长度为 nn 的字符串,由字母 b(白色)和 c(黑色)组成,依次表示各积木的颜色。

所有测试数据保证存在移除所有积木的操作序列。

输出格式

输出 nk+1\frac{n}{k+1} 行,每行描述一次操作,包含 k+1k+1 个按升序排列的整数(用单个空格分隔),表示该操作移除的积木编号。

12 2
ccbcbbbbbbcb

1 8 12
2 6 7
3 4 5
9 10 11

\sqcup 代表被移除的块所留下的空白空间。通过执行上述移动,我们获得以下块排列:

$$\begin{array}{cccccccccccc} 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\ \hline \texttt{c} & \texttt{c} & \texttt{b} & \texttt{c} & \texttt{b} & \texttt{b} & \texttt{b} & \texttt{b} & \texttt{b} & \texttt{b} & \texttt{c} & \texttt{b} \\ \sqcup & \texttt{c} & \texttt{b} & \texttt{c} & \texttt{b} & \texttt{b} & \texttt{b} & \sqcup & \texttt{b} & \texttt{b} & \texttt{c} & \sqcup \\ \sqcup & \sqcup & \texttt{b} & \texttt{c} & \texttt{b} & \sqcup & \sqcup & \sqcup & \texttt{b} & \texttt{b} & \texttt{c} & \sqcup \\ \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \texttt{b} & \texttt{b} & \texttt{c} & \sqcup \\ \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup & \sqcup \end{array} $$

数据范围与提示

对于 40%40\% 的数据,n10000n \leq 10000