이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |