Submission #613749

#TimeUsernameProblemLanguageResultExecution timeMemory
613749Jarif_RahmanCounting Mushrooms (IOI20_mushrooms)C++17
67.06 / 100
11 ms344 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; const int k = 94; int count_mushrooms(int n){ if(n <= 227){ int ans = 1; for(int i = 1; i < n; i++) if(!use_machine({0, i})) ans++; return ans; } vector<int> A, B; A.pb(0); int ls = n, ans; for(int i = 1; i < n; i++){ if(use_machine({0, i})) B.pb(i); else A.pb(i); if(max(A.size(), B.size()) == k){ ls = i+1; break; } } ans = A.size(); while(ls < n){ if(A.size() > B.size()){ int sz = A.size(); vector<int> Q; for(int i = 0; i < sz; i++){ Q.pb(A[i]); if(ls+i < min(n, ls+sz)) Q.pb(ls+i); } int x = use_machine(Q); ans+=min(n, ls+sz)-ls-x%2-x/2; if(x%2) B.pb(ls+sz-1); else A.pb(ls+sz-1); ls+=sz; } else{ int sz = B.size(); vector<int> Q; for(int i = 0; i < sz; i++){ Q.pb(B[i]); if(ls+i < min(n, ls+sz)) Q.pb(ls+i); } int x = use_machine(Q); ans+=x%2+x/2; if(x%2) A.pb(ls+sz-1); else B.pb(ls+sz-1); ls+=sz; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...