Submission #589835

#TimeUsernameProblemLanguageResultExecution timeMemory
589835LucppCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
11 ms448 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int ans = 1; vector<int> a{0}, b; int i = 1; while(i < n){ if(a.size() > b.size()){ int s = min((int)a.size(), n-i); vector<int> m; int k = 0; for(int j = i; j < i+s; j++){ m.push_back(a[k++]); m.push_back(j); } int x = use_machine(m); ans += s-(x+1)/2; if(x%2 == 0) a.push_back(i+s-1); else b.push_back(i+s-1); i += s; } else{ int s = min((int)b.size(), n-i); vector<int> m; int k = 0; for(int j = i; j < i+s; j++){ m.push_back(b[k++]); m.push_back(j); } int x = use_machine(m); ans += (x+1)/2; if(x%2 == 0) b.push_back(i+s-1); else a.push_back(i+s-1); i += s; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...