제출 #1186622

#제출 시각아이디문제언어결과실행 시간메모리
1186622al95ireyizTake-out (POI13_usu)C++20
0 / 100
55 ms12260 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; string s; cin >> s; vector<pair<int,int>> st; st.reserve(n); for(int i = 0; i < n; i++){ bool is_white = (s[i] == 'b'); // 'b' = white, 'c' = black int cum_white = is_white ? (st.empty() ? 1 : st.back().first + 1) : (st.empty() ? 0 : st.back().first); st.emplace_back(cum_white, i+1); while ((int)st.size() >= k+1) { int pos = st.size() - 1; int bot = pos - k; int whites = st[pos].first - (bot > 0 ? st[bot-1].first : 0); if (whites != k) break; vector<int> move; move.reserve(k+1); for(int j = bot; j <= pos; j++) move.push_back(st[j].second); sort(move.begin(), move.end()); for(int x = 0; x < (int)move.size(); x++){ if (x) cout << ' '; cout << move[x]; } cout << '\n'; for(int j = 0; j < k+1; j++) st.pop_back(); } } return 0; }
#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...