# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1035365 | Gray | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 600 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"
#define ff first
#define ss second
#define ll int
#define ln "\n"
using namespace std;
int qry=200;
int count_mushrooms(int n) {
std::vector<int> query;
vector<int> as, bs;
as.push_back(0);
for (ll i=1; i<min(qry+1, n); i++){
query = {0, (int)i};
ll ret=use_machine(query);
if (ret==0) as.push_back(i);
else bs.push_back(i);
}
ll ans=(ll)as.size();
if (as.size()>bs.size()){
for (ll i=min(qry+1, n); i<n; i+=as.size()-1){
query.clear();
for (ll j=0; j<(ll)as.size()-1 and i+j<n; j++){
query.push_back(as[j]);
query.push_back(i+j);
}
query.push_back(as.back());
ll ret = use_machine(query)/2ll;
ans+=(query.size()-1)/2-ret;
}
}else{
for (ll i=min(qry+1, n); i<n; i+=bs.size()-1){
query.clear();
for (ll j=0; j<(ll)bs.size()-1 and i+j<n; j++){
query.push_back(bs[j]);
query.push_back(i+j);
}
query.push_back(bs.back());
ll ret = use_machine(query)/2ll;
ans+=ret;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |