# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
750304 | mohav48173 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 13 ms | 316 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;
const int cnt=300;
int count_mushrooms(int n) {
vector<int>a,b;
a.push_back(0);
for(int i=1;i<=min(n-1,cnt);i++) {
if(use_machine({0,i})==0)a.push_back(i);
else b.push_back(i);
}
int ans=a.size();
vector<int>cur;
for(int i=cnt+1;i<n;i++) {
cur.push_back(i);
if(cur.size()>=max((int)a.size(),(int)b.size())) {
vector<int>ask;
bool flag=0;
if(a.size()<b.size()){swap(a,b);flag=1;}
for(int j=0;j<cur.size();j++) {
ask.push_back(a[j]);
ask.push_back(cur[j]);
}
int current=use_machine(ask);
int nums=0;
nums+=current%2;
current-=current%2;
nums+=current/2;
if(!flag)nums=cur.size()-nums;
ans+=nums;
if(flag)swap(a,b);
cur.clear();
}
}
if(cur.size()!=0) {
vector<int>ask;
bool flag=0;
if(a.size()<b.size()){swap(a,b);flag=1;}
for(int j=0;j<cur.size();j++) {
ask.push_back(a[j]);
ask.push_back(cur[j]);
}
int current=use_machine(ask);
int nums=0;
nums+=current%2;
current-=current%2;
nums+=current/2;
if(!flag)nums=cur.size()-nums;
ans+=nums;
if(flag)swap(a,b);
cur.clear();
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |