# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589835 | Lucpp | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 448 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) {
int ans = 1;
vector<int> a{0}, b;
int i = 1;
while(i < n){
if(a.size() > b.size()){
int s = min((int)a.size(), n-i);
vector<int> m;
int k = 0;
for(int j = i; j < i+s; j++){
m.push_back(a[k++]);
m.push_back(j);
}
int x = use_machine(m);
ans += s-(x+1)/2;
if(x%2 == 0) a.push_back(i+s-1);
else b.push_back(i+s-1);
i += s;
}
else{
int s = min((int)b.size(), n-i);
vector<int> m;
int k = 0;
for(int j = i; j < i+s; j++){
m.push_back(b[k++]);
m.push_back(j);
}
int x = use_machine(m);
ans += (x+1)/2;
if(x%2 == 0) b.push_back(i+s-1);
else a.push_back(i+s-1);
i += s;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |