# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613749 | Jarif_Rahman | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 344 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |