Submission #303549

#TimeUsernameProblemLanguageResultExecution timeMemory
303549galcaCounting Mushrooms (IOI20_mushrooms)C++14
63.31 / 100
14 ms416 KiB
#include "mushrooms.h" using namespace std; int count_mushrooms(int n) { vector<int> knownZeros; vector<int> knownOnes; knownZeros.push_back(0); vector<int> pairs; pairs.push_back(0); pairs.push_back(0); if (n <= 128) { for (int i = 1; i < n; i++) { pairs[1] = i; int c = use_machine(pairs); if (c) { knownOnes.push_back(i); } else { knownZeros.push_back(i); } } return knownZeros.size(); } for (int i = 1; i < 128; i++) { pairs[1] = i; int c = use_machine(pairs); if (c) { knownOnes.push_back(i); } else { knownZeros.push_back(i); } } int i = 128; int totalZeros = knownZeros.size(); while (i < n) { vector<int> m; if (knownOnes.size() >= knownZeros.size()) { for (int j = 0; j < knownOnes.size(); j++) { if ((i + j) < n) { m.push_back(knownOnes[j]); m.push_back(i + j); } } int c = use_machine(m); if (c & 1) { ++totalZeros; --c; knownZeros.push_back(m[m.size() - 1]); } totalZeros += c / 2; i += knownOnes.size(); } else { for (int j = 0; j < knownZeros.size(); j++) { if ((i + j) < n) { m.push_back(knownZeros[j]); m.push_back(i + j); } } int c = use_machine(m); if (c & 1) { ++c; knownOnes.push_back(m[m.size() - 1]); } totalZeros += (m.size() - c) / 2; i += knownZeros.size(); } } return totalZeros; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |    for (int j = 0; j < knownOnes.size(); j++) {
      |                    ~~^~~~~~~~~~~~~~~~~~
mushrooms.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |    for (int j = 0; j < knownZeros.size(); j++) {
      |                    ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...