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