# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424304 | Apiram | Counting Mushrooms (IOI20_mushrooms) | C++14 | 1 ms | 200 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>a,b;
a.push_back(0);
int ans=0;
vector<int>both;
for (int i =1;i<n;++i){
both.push_back(i);
if (both.size()!=max(a.size(),b.size()))continue;
if (a.size()>b.size()){
vector<int>cur;
for (int i =0;i<both.size();++i){
cur.push_back(both[i]);
cur.push_back(a[i]);
}
int k = use_machine(cur);
ans+=(k + 1)/2 - 1;
if (k%2==1){
a.push_back(cur[0]);
}
else b.push_back(cur[0]);
}
else {
vector<int>cur;
for (int i =0;i<both.size();++i){
cur.push_back(both[i]);
cur.push_back(b[i]);
}
int k = use_machine(cur);
ans+=cur.size() - (k + 1)/2 ;
if (k%2==1){
b.push_back(cur[0]);
}
else a.push_back(cur[0]);
}
both.clear();
}
if (!both.empty()){
if (a.size()>b.size()){
vector<int>cur;
for (int i =0;i<both.size();++i){
cur.push_back(both[i]);
cur.push_back(a[i]);
}
int k = use_machine(cur);
ans+=(k + 1)/2 - 1;
if (k%2==1){
a.push_back(cur[0]);
}
else b.push_back(cur[0]);
}
else {
vector<int>cur;
for (int i =0;i<both.size();++i){
cur.push_back(both[i]);
cur.push_back(b[i]);
}
int k = use_machine(cur);
ans+=cur.size() - (k + 1)/2 ;
if (k%2==1){
b.push_back(cur[0]);
}
else a.push_back(cur[0]);
}
}
return ans + a.size();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |