# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
759042 | Charizard2021 | Take-out (POI13_usu) | C++17 | 156 ms | 39040 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;
int main() {
int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<int> val;
vector<int> x;
x.push_back(0);
int cVal = 0;
vector<vector<int> > ans;
for(int i = 0; i < n; i++){
val.push_back(i);
if(s[i] == 'c'){
x.push_back(0);
cVal++;
}
else{
x[cVal]++;
}
if(cVal != 0 && x[cVal] + x[cVal - 1] >= k){
vector<int> v2;
ans.push_back(v2);
for(int j = 0; j <= k; j++){
ans[(int)ans.size() - 1].push_back(val[(int)val.size() - 1]);
val.pop_back();
}
int difference = x[cVal];
cVal--;
x.pop_back();
x[cVal] -= (k - difference);
}
}
reverse(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++){
for(int j = ans[i].size() - 1; j >= 0; j--){
cout << ans[i][j] + 1 << " ";
}
cout << "\n";
}
}
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... |