import java.util.*;
import java.io.*;
public class usu {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
ArrayDeque<A> bs, ans;
bs = new ArrayDeque<>();
ans = new ArrayDeque<>();
ArrayDeque<Integer> ws = new ArrayDeque<>();
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
A.K = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
String S = st.nextToken();
for (int i=0;i<N;i++) {
if (S.charAt(i)=='b') {
ws.push(i);
while (!bs.isEmpty() && !ws.isEmpty()) {
while (!bs.peek().isFilled() && !ws.isEmpty())
bs.peek().add(ws.pop());
if (bs.peek().isFilled()) ans.push(bs.pop());
}
}
else {
bs.push(new A(i));
}
}
while (!bs.isEmpty() && !ws.isEmpty()) {
while (!bs.peek().isFilled() && !ws.isEmpty())
bs.peek().add(ws.pop());
if (bs.peek().isFilled()) ans.push(bs.pop());
}
while (!ans.isEmpty()) pw.println(ans.pop().toString());
pw.close();
}
}
class A {
int [] white;
int black;
static int K;
int ind;
public A(int b) {
black = b+1;
ind = 0;
white = new int[K+1];
}
public void add(int x) {
white[ind] = x+1;
ind++;
}
public boolean isFilled() {
return ind>=K;
}
public String toString() {
white[K] = black;
Arrays.sort(white);
String S = "";
for (int i=0;i<K;i++) S+=white[i]+" ";
S+=white[K];
return S;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |