# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424163 | Supersonic | Counting Mushrooms (IOI20_mushrooms) | C++14 | 12 ms | 336 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 o(int n){
int b=-1,m=1e9;
for(int i=1;i<n;i++){
if(2*i+(n-(2*i))/i<m){m=2*i+(n-(2*i))/i;b=i;}
}
return max(2,b);
}
int count_mushrooms(int n) {
vector<int> a={0};
vector<int> b;int c=1;
int p=o(n);
while(a.size()<p&&b.size()<p&&c<n){
int k=use_machine({0,c});
if(k==1)b.push_back(c);else a.push_back(c);
c++;
}
int ca=a.size(),cb=b.size();
if(c==n)return ca;
if(a.size()==p){
//cerr<<a[0]<<':'<<a[1]<<endl;
while(c<n){
vector<int> r;
for(auto i:a){r.push_back(i);r.push_back(c);c++;if(c==n)break;}
//for(auto i:r)cerr<<i<<' ';cerr<<endl;
int k=use_machine(r);if(k%2==0)a.push_back(r.back());
cb+=(k+1)/2;
}
return n-cb;
}
else {
while(c<n){
vector<int> r;
for(auto i:b){r.push_back(i);r.push_back(c);c++;if(c==n)break;}
//for(auto i:r)cerr<<i<<' ';cerr<<endl;
int k=use_machine(r);if(k%2==0)b.push_back(r.back());
ca+=(k+1)/2;
}
return ca;
}
exit(1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |