Submission #828686

#TimeUsernameProblemLanguageResultExecution timeMemory
828686Minindu206Counting Mushrooms (IOI20_mushrooms)C++14
45.47 / 100
9 ms336 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> posa, posb, pos; int acnt = 1, bcnt = 0, cnt, ans = 0; posa.push_back(0); for (int i = 1; i < min(100, n); i++) { int cur = use_machine({0, i}); if (cur == 0) { posa.push_back(i); acnt++; } else { posb.push_back(i); bcnt++; ans++; } } if (n <= 100) { return n - ans; } if (acnt >= bcnt) pos = posa; else pos = posb; int i = 100; vector<int> chk; while (i < n) { chk.clear(); int cur = 0, vr = i + pos.size(); for(;i<min(vr, n) && cur < pos.size();i++) { chk.push_back(i); chk.push_back(pos[cur]); cur++; } int ncur = use_machine(chk); if (acnt >= bcnt) ans += (ncur + 1) / 2; else ans += (cur - ((ncur + 1) / 2)); } return n - ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:41:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(;i<min(vr, n) && cur < pos.size();i++)
      |                        ~~~~^~~~~~~~~~~~
mushrooms.cpp:7:26: warning: unused variable 'cnt' [-Wunused-variable]
    7 |  int acnt = 1, bcnt = 0, cnt, ans = 0;
      |                          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...