# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28983 | khsoo01 | Take-out (POI13_usu) | C++11 | 233 ms | 32944 KiB |
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;
typedef pair<int,int> pii;
const int N = 1000005;
int n, k, c;
char a[N];
vector<int> v, p;
vector<vector<int> > ans;
int main()
{
scanf("%d%d%s",&n,&k,a+1);
p.push_back(0);
for(int i=1;i<=n;i++) {
v.push_back(i);
if(a[i] == 'c') {c++; p.push_back(0);}
else p[c]++;
if(c && p[c] + p[c-1] >= k) {
vector<int> T;
for(int i=0;i<k+1;i++) {
T.push_back(v.back());
v.pop_back();
}
reverse(T.begin(), T.end());
ans.push_back(T);
int X = p[c--]; p.pop_back();
p[c] -= k - X;
}
}
for(int i=ans.size();i--;) {
for(auto &T : ans[i]) {
printf("%d ",T);
}
puts("");
}
}
Compilation message (stderr)
# | 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... |