제출 #28991

#제출 시각아이디문제언어결과실행 시간메모리
28991kdh9949새로운 문제 (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(); } }

컴파일 시 표준 에러 (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...