# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347306 | Pherokung | Counting Mushrooms (IOI20_mushrooms) | C++14 | 31 ms | 648 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 all,be,mid,ed,arr[20005],type,ans=1;
vector<int> v;
void mush(int be,int ed,int val){
if(val == 0 || be == ed) return;
if(val == ed-be){
for(int i=be+1;i<=ed;i++) arr[i] = 1;
return;
}
int mid = (be+ed)/2,f,s;
v.clear();
v.push_back(mid);
v.push_back(mid+1);
if(use_machine(v)){
val--;
arr[mid+1] = 1;
}
v.clear();
for(int i=be;i<=mid;i++) v.push_back(i);
f = use_machine(v);
mush(be,mid,f);
s = val-f;
mush(mid+1,ed,s);
return;
}
int count_mushrooms(int n) {
for (int i = 0; i < n; i++) v.push_back(i);
all = use_machine(v);
mush(0,n-1,all);
type = 0;
for(int i=1;i<n;i++){
type += arr[i];
if(type % 2 == 0) ans++;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |