Submission #759753

#TimeUsernameProblemLanguageResultExecution timeMemory
759753MilosMilutinovicCounting Mushrooms (IOI20_mushrooms)C++14
0 / 100
17 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int C = 100; int count_mushrooms(int n) { if (n <= 227) { int ans = 1; for (int i = 1; i < n; i++) { ans += !use_machine({0, i}); } return ans; } vector<int> a(1, 0), b; for (int i = 1; i < min(n, C); i++) { if (use_machine({0, i})) b.push_back(i); else a.push_back(i); } int ans = a.size(); for (int i = C; i < n; i++) { int sz = max(a.size(), b.size()); vector<int> qv; for (int j = i; j < min(i + sz + 1, n); j++) { if (j != i + sz) { if (a.size() == sz) qv.push_back(a[j - i]); else qv.push_back(b[j - i]); } qv.push_back(j); } int diff = (use_machine(qv) + 1) / 2; int same = (qv.size() - sz - diff); if (a.size() == sz) ans += same; else ans += diff; } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:26:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |                 if (a.size() == sz)
      |                     ~~~~~~~~~^~~~~
mushrooms.cpp:35:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |         if (a.size() == sz)
      |             ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...