Submission #28983

#TimeUsernameProblemLanguageResultExecution timeMemory
28983khsoo01Take-out (POI13_usu)C++11
100 / 100
233 ms32944 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int N = 1000005; int n, k, c; char a[N]; vector<int> v, p; vector<vector<int> > ans; int main() { scanf("%d%d%s",&n,&k,a+1); p.push_back(0); for(int i=1;i<=n;i++) { v.push_back(i); if(a[i] == 'c') {c++; p.push_back(0);} else p[c]++; if(c && p[c] + p[c-1] >= k) { vector<int> T; for(int i=0;i<k+1;i++) { T.push_back(v.back()); v.pop_back(); } reverse(T.begin(), T.end()); ans.push_back(T); int X = p[c--]; p.pop_back(); p[c] -= k - X; } } for(int i=ans.size();i--;) { for(auto &T : ans[i]) { printf("%d ",T); } puts(""); } }

Compilation message (stderr)

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