Submission #825486

#TimeUsernameProblemLanguageResultExecution timeMemory
825486benjaminkleynCounting Mushrooms (IOI20_mushrooms)C++17
71.52 / 100
7 ms456 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> A(1, 0), B; int k = 73; int i = 1; for (; i < n && A.size() < k && B.size() < k; i++) if (use_machine({0, i})) B.push_back(i); else A.push_back(i); int cnt = A.size(); while (i < n) { vector<int> query; if (A.size() >= B.size()) { for (int j : A) { query.push_back(j); query.push_back(i++); if (i >= n) break; } int x = use_machine(query); cnt += query.size() / 2 - (x + 1) / 2; if (x % 2) B.push_back(query.back()); else A.push_back(query.back()); } else { for (int j : B) { query.push_back(j); query.push_back(i++); if (i >= n) break; } int x = use_machine(query); cnt += (x + 1) / 2; if (x % 2) A.push_back(query.back()); else B.push_back(query.back()); } } return cnt; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:10:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     for (; i < n && A.size() < k && B.size() < k; i++)
      |                     ~~~~~~~~~^~~
mushrooms.cpp:10:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     for (; i < n && A.size() < k && B.size() < k; i++)
      |                                     ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...