이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 100;
int N, K, pref[MAXN], temp[MAXN];
vector<vector<int>> ans;
string S;
int main() {
fast;
cin >> N >> K >> S;
S = "#" + S;
int now = 0;
for (int i = 1; i <= N; i++) {
now++;
pref[now] = pref[now-1] + (S[i] == 'c');
temp[now] = i;
if (now >= K + 1 && pref[now] - pref[now - K - 1] == 1) {
ans.push_back(vector<int>());
for (int j = now; j >= now - K; j--)
ans.back().push_back(temp[j]);
sort(ans.back().begin(), ans.back().end());
now -= K + 1;
}
}
reverse(ans.begin(), ans.end());
for (auto v : ans) {
for (auto q : v)
cout << q << " ";
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... |