Submission #882879

#TimeUsernameProblemLanguageResultExecution timeMemory
882879MatjazMiners (IOI07_miners)C++14
45 / 100
1553 ms1188 KiB
// // MinersIOI2007.cpp // // // Created by Matjaz Leonardis on 04/12/2023. // #include <iostream> #include <string> #include <vector> using namespace std; // Trying all the different Miners solutions int N; string food; int coal(string s){ int res = 0; for (int i=0;i<s.size();i++){ bool m=false,b=false,f=false; for (int j=i;j>i-3 && j>=0;j--){ if (s[j] == 'M') m = true; if (s[j] == 'F') f = true; if (s[j] == 'B') b = true; } res += m + f + b; } return res; } int main(){ cin >> N; cin >> food; int best = 0; for (int i=0;i<(1<<N);i++){ string mine1; string mine2; for (int j=0;j<N;j++) if ((i&(1<<j)) != 0) mine1 += food[j]; else mine2 += food[j]; best = max(best, coal(mine1) + coal(mine2)); } cout << best << endl; return 0; }

Compilation message (stderr)

miners.cpp: In function 'int coal(std::string)':
miners.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i=0;i<s.size();i++){
      |                  ~^~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...