# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613703 | Jarif_Rahman | Counting Mushrooms (IOI20_mushrooms) | C++17 | 9 ms | 460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |