Submission #1087946

#TimeUsernameProblemLanguageResultExecution timeMemory
1087946vicvicTake-out (POI13_usu)C++11
0 / 100
1069 ms36972 KiB
#include <iostream> #include <fstream> #include <vector> #include <string> #include <cstring> using namespace std; int n, k, cnt=0, p=0; string input; vector <pair <int, int>> v[500005]; bool can_place (int p, char a) { int frecv[3]={0}; for (int i=0;i<v[p].size();i++) { frecv[v[p][i].first-'b']++; } return ((a=='c' && frecv[1]==0) || (a=='b' && frecv[0]<k)); } int main() { cin >> n >> k; cin >> input; input=" "+input; for (int i=1;i<=n;i++) { if (p==0 || can_place (p, input[i])) { if (p==0) { cnt++; p=cnt; } v[p].push_back ({input[i], i}); if (v[p].size()==k+1) { p--; } } else { cnt++; p++; v[p].push_back ({input[i], i}); } } for (int i=1;i<=n/(k+1);i++) { for (auto itr : v[i]) { cout << itr.second << " "; } cout << "\n"; } return 0; }

Compilation message (stderr)

usu.cpp: In function 'bool can_place(int, char)':
usu.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i=0;i<v[p].size();i++)
      |                  ~^~~~~~~~~~~~
usu.cpp: In function 'int main()':
usu.cpp:34:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |             if (v[p].size()==k+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...