Submission #613703

#TimeUsernameProblemLanguageResultExecution timeMemory
613703Jarif_RahmanCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
9 ms460 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int count_mushrooms(int n){ vector<int> A, B; A.pb(0); int ls = n; for(int i = 1; i < n; i++){ if(max(A.size(), B.size()) == 2){ ls = i; break; } if(use_machine({0, i})) B.pb(i); else A.pb(i); } int ans = A.size(); while(ls < n){ if(A.size() > B.size()){ int k = A.size(); vector<int> Q; for(int i = 0; i < k; i++){ Q.pb(A[i]); if(ls+i < min(n, ls+k)) Q.pb(ls+i); } int x = use_machine(Q); ans+=min(n, ls+k)-ls-x%2-x/2; if(x%2) B.pb(ls+k-1); else A.pb(ls+k-1); ls+=k; } else{ int k = B.size(); vector<int> Q; for(int i = 0; i < k; i++){ Q.pb(B[i]); if(ls+i < min(n, ls+k)) Q.pb(ls+i); } int x = use_machine(Q); ans+=x%2+x/2; if(x%2) A.pb(ls+k-1); else B.pb(ls+k-1); ls+=k; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...