QOJ.ac

QOJ

Time Limit: 0.5 s Memory Limit: 64 MB Total points: 100

#13316. 外卖

Statistics

小 Edna 收到了一份“消除游戏”作为礼物。这是一个单人游戏,玩家会得到一个由 $n$ 个相邻方块组成的序列,编号从 $1$ 到 $n$。每个方块要么是白色,要么是黑色,且白色方块的数量是黑色方块的 $k$ 倍。

玩家的目标是通过一系列允许的操作移除所有方块。

单次操作包括移除恰好 $k$ 个白色方块和一个黑色方块,且不改变其他方块的位置。如果被移除的方块之间没有“空隙”(即之前移除方块后留下的空格),则该操作是允许的。

请帮助可怜的小 Edna 找到任何一种能够移除所有方块的操作序列。

输入格式

标准输入的第一行包含两个整数 $n$ 和 $k$ ($2 \le n \le 1\,000\,000$, $1 \le k \le n-1$),由单个空格分隔,分别表示游戏中使用的方块总数,以及每次操作中需要移除的白色方块与黑色方块的比例。在所有测试数据中,满足 $k+1 \mid n$。

第二行包含一个长度为 $n$ 的字符串,由字母 bc 组成。这些字母表示连续方块的颜色(源自波兰语):b(biały)代表白色,c(czarny)代表黑色。你可以假设在所有测试数据中,都存在一种能够移除所有方块的操作序列。

输出格式

你的程序应向标准输出打印多行内容。每一行描述一次操作。每行应包含 $k+1$ 个整数,按升序排列,由单个空格分隔,表示该次操作中被移除的方块编号。

样例

输入 1

12 2
ccbcbbbbbbcb

输出 1

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

说明

令 $\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} $$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.