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;
#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... |