This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
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... |