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>
#define ll long long
#define ull unsigned long long
#define lsb(x) (x & (-x))
using namespace std;
const int MAXN = (int) 1e6;
char str[MAXN + 1];
int sp[MAXN + 1], pos[MAXN + 1];
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, n, k;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k >> (str + 1);
vector < vector <int> > sol(n / (k + 1) + 1);
int sz = 0, cur = 0;
for(i = 1; i <= n; i++) {
sz++;
sp[sz] = sp[sz - 1] + (str[i] == 'c');
pos[sz] = i;
if(sz >= k + 1 && sp[sz] - sp[sz - k - 1] == 1) {
cur++;
for(int j = k; j >= 0; j--) {
sol[cur].push_back(pos[sz - j]);
}
sz -= (k + 1);
}
}
for(i = n / (k + 1); i >= 1; i--) {
for(auto it : sol[i]) {
cout << it << " ";
}
cout << "\n";
}
return 0;
}
# | 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... |