#include <bits/stdc++.h>
using namespace std;
int N, K;
int main() {
cin >> N >> K;
vector<bool> arr(N+1); // White is False, Black is True
string s;
cin >> s;
for (int i = 0; i < N; i++) {
arr[i+1] = (s[i] == 'c');
}
stack<int> white, black;
vector<vector<int>> ans;
for (int i = 1; i <= N; i++) {
if (arr[i]) {
black.push(i);
}
else {
white.push(i);
}
if (((int)white.size() >= K) && (!black.empty())) {
vector<int> cur;
cur.push_back(black.top());
black.pop();
for (int j = 1; j <= K; j++) {
cur.push_back(white.top());
white.pop();
}
sort(cur.begin(), cur.end());
ans.push_back(cur);
}
}
for (int i = 0; i < N/(K+1); i++) {
for (auto v: ans[i]) {
cout << v << " ";
} cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Ruch numer 3 nie jest poprawny. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Ruch numer 10 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Ruch numer 200 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Incorrect |
2 ms |
340 KB |
Ruch numer 9 nie jest poprawny. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
2316 KB |
Ruch numer 10000 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
3140 KB |
Ruch numer 10002 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
6664 KB |
Ruch numer 2500 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
9564 KB |
Ruch numer 4000 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
206 ms |
36256 KB |
Ruch numer 500000 nie jest poprawny. |
2 |
Halted |
0 ms |
0 KB |
- |