Submission #746204

#TimeUsernameProblemLanguageResultExecution timeMemory
746204JellyTheOctopusTake-out (POI13_usu)C++17
100 / 100
235 ms36268 KiB
#include <bits/stdc++.h> using namespace std; int N, K; string str; int main() { cin >> N >> K; cin >> str; vector<bool> arr(N+1); for (int i = 1; i <= N; i++) { arr[i] = (str[i-1] == 'c'); } stack<int> ind; vector<int> space; space.push_back(0); int c = 0; vector<vector<int>> ans; for (int i = 1; i <= N; i++) { ind.push(i); if (arr[i]) { c++; space.push_back(0); } else { space[c]++; } if (c && (space[c]+space[c-1]) >= K) { vector<int> cur; for (int j = 0; j < K+1; j++) { cur.push_back(ind.top()); ind.pop(); } reverse(cur.begin(), cur.end()); ans.push_back(cur); int diff = space[c--]; space.pop_back(); space[c] -= K-diff; } } reverse(ans.begin(), ans.end()); for (auto cur: ans) { for (auto v: cur) { cout << v << " "; } cout << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...