# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388062 | Supersonic | Counting Mushrooms (IOI20_mushrooms) | C++14 | 11 ms | 328 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 k=141;
vector<int> a;vector<int> b;a.push_back(0);
int r1=use_machine({0,1});if(r1)b.push_back(1);else a.push_back(1);
if(n==2)return a.size();
int r2=use_machine({0,2});if(r2)b.push_back(2);else a.push_back(2);
if(n==3)return a.size();
int c=3;
if(a.size()>=2){
while(c<n-1&&max(a.size(),b.size())<k){
r1=use_machine({a[0],c,a[1],c+1});
if(r1==0){a.push_back(c);a.push_back(c+1);}
if(r1==1){a.push_back(c);b.push_back(c+1);}
if(r1==2){b.push_back(c);a.push_back(c+1);}
if(r1==3){b.push_back(c);b.push_back(c+1);}
c+=2;
}
}
else{
while(c<n-1&&max(a.size(),b.size())<k){
r1=use_machine({b[0],c,b[1],c+1});
if(r1==0){b.push_back(c);b.push_back(c+1);}
if(r1==1){b.push_back(c);a.push_back(c+1);}
if(r1==2){a.push_back(c);b.push_back(c+1);}
if(r1==3){a.push_back(c);a.push_back(c+1);}
c+=2;
}
}
if(c==n-1){
if(use_machine({0,n-1})==1)b.push_back(n-1);
else a.push_back(n-1);
c++;
}
if(c==n)return a.size();
int as=a.size();
while(c<n){
if(a.size()>b.size()){
vector<int> q;int t=0;
for(auto i:a){q.push_back(i);t++;q.push_back(c);c++;if(c==n)break;}
r1=use_machine(q);
if(r1%2==1)b.push_back(q[q.size()-1]);
r1++;r1/=2;as+=(t-r1);
}
else {
vector<int> q;
for(auto i:b){q.push_back(i);q.push_back(c);c++;if(c==n)break;}
r1=use_machine(q);
if(r1%2==1)a.push_back(q[q.size()-1]);
r1++;r1/=2;as+=r1;
}
}
return as;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |