Submission #28991

#TimeUsernameProblemLanguageResultExecution timeMemory
28991kdh9949Take-out (POI13_usu)C++14
22 / 100
189 ms27728 KiB
#include <bits/stdc++.h> using namespace std; struct Dat{ int *p, b, c; }; int n, k; char str[1000010]; stack<Dat> st, nst; void upd(int i){ st.top().p[st.top().b + st.top().c] = i; if(str[i] == 'b') st.top().b++; else st.top().c++; } void top(int i){ int *p = new int[k + 1]; st.push({p, 0, 0}); upd(i); } void pop(){ nst.push(st.top()); st.pop(); } int main(){ scanf("%d%d%s", &n, &k, str + 1); for(int i = 1; i <= n; i++){ if(st.empty()) top(i); else if(str[i] == 'b'){ if(st.top().b == k) top(i); else upd(i); if(st.top().b + st.top().c == k + 1){ pop(); } } else{ if(st.top().c == 1) top(i); else upd(i); if(st.top().b + st.top().c == k + 1){ pop(); } } } while(!nst.empty()){ for(int i = 0; i <= k; i++) printf("%d ", nst.top().p[i]); puts(""); nst.pop(); } }

Compilation message (stderr)

usu.cpp: In function 'int main()':
usu.cpp:30:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s", &n, &k, str + 1);
                                  ^
#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...