# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995156 | emptypringlescan | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 736 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>
using namespace std;
int count_mushrooms(int n){
vector<int> r,b;
r.push_back(0);
int cur=1,ans=1;
while(cur<n){
if(r.size()>=b.size()){
vector<int> test;
for(int i=0; i<(int)r.size(); i++){
if(cur+i>=n) break;
test.push_back(cur+i);
test.push_back(r[i]);
}
int x=use_machine(test);
ans+=(int)test.size()/2-(x+1)/2;
if(x%2) b.push_back(cur);
else r.push_back(cur);
cur+=(int)test.size()/2;
}
else{
vector<int> test;
for(int i=0; i<(int)b.size(); i++){
if(cur+i>=n) break;
test.push_back(cur+i);
test.push_back(b[i]);
}
int x=use_machine(test);
ans+=(x+1)/2;
if(x%2) r.push_back(cur);
else b.push_back(cur);
cur+=(int)test.size()/2;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |