Submission #1087969

#TimeUsernameProblemLanguageResultExecution timeMemory
1087969vicvicTake-out (POI13_usu)C++11
22 / 100
148 ms58736 KiB
#include <iostream> #include <fstream> #include <vector> #include <string> #include <cstring> #include <cassert> using namespace std; int n, k, cnt=0, p=0; string input; int frecv[1000005][5]; vector <int> v[1000005]; int main() { cin >> n >> k; cin >> input; input=" "+input; for (int i=1;i<=n;i++) { if ((p>0 && v[p].size()<(k+1)) && ((input[i]=='b' && frecv[p][0]<k) || (input[i]=='c' && frecv[p][1]==0))) { frecv[p][input[i]-'b']++; v[p].push_back (i); while (v[p].size()==k+1 && p>0) { p--; } } else { cnt++; p=cnt; frecv[p][input[i]-'b']++; v[p].push_back (i); } } for (int i=1;i<=n/(k+1);i++) { for (auto itr : v[i]) { cout << itr << " "; } cout << "\n"; } return 0; }

Compilation message (stderr)

usu.cpp: In function 'int main()':
usu.cpp:19:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         if ((p>0 && v[p].size()<(k+1)) && ((input[i]=='b' && frecv[p][0]<k) || (input[i]=='c' && frecv[p][1]==0)))
      |                     ~~~~~~~~~~~^~~~~~
usu.cpp:23:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |             while (v[p].size()==k+1 && p>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...