Submission #825488

#TimeUsernameProblemLanguageResultExecution timeMemory
825488benjaminkleynCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
8 ms456 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> A(1, 0), B; int i = 1; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...