Submission #746200

#TimeUsernameProblemLanguageResultExecution timeMemory
746200JellyTheOctopusTake-out (POI13_usu)C++17
23 / 100
237 ms37196 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<array<int, 3>> s; // index, # of C, # of B vector<vector<int>> ans; for (int i = 1; i <= N; i++) { if (!s.empty()) { s.push({i, s.top()[1]+arr[i], s.top()[2]+!arr[i]}); } else { s.push({i, arr[i], !arr[i]}); } while (!s.empty() && s.top()[1] && s.top()[2] >= K) { vector<int> cur; for (int i = 0; i < K+1; i++) { cur.push_back(s.top()[0]); s.pop(); } reverse(cur.begin(), cur.end()); ans.push_back(cur); } } 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...