# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367538 | rumen_m | Counting Mushrooms (IOI20_mushrooms) | C++17 | 139 ms | 788 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;
vector <int> l[2];
const int K = 200000;
int ans = 1;
int count_mushrooms(int n) {
int i,j;
l[0].push_back(0);
int x,y,type;
vector <int> m;
if(n==2)
{
m.push_back(0);
m.push_back(1);
int z = use_machine(m);
return (z==0) ? 2 : 1;
}
for(i=1;i<=2;i++)
{
m.clear();
m.push_back(0);
m.push_back(i);
int z = use_machine(m);
l[z].push_back(i);
}
if(l[0].size()>=2)
{
type = 0;
x = l[0][0];
y = l[0][1];
}
else
{
type = 1;
x = l[1][0];
y = l[1][1];
}
i = 3;
// l[0].push_back(0);
while(i+1<n&&l[0].size()<K&&l[1].size()<K)
{
m.clear();
m.push_back(i);
i++;
m.push_back(x);
m.push_back(i);
i++;
m.push_back(y);
int z = use_machine(m);
l[(z&1)^type].push_back(i-2);
l[((z&10)>>1)^type].push_back(i-1);
}
//cout<<"Here"<<endl;
ans = l[0].size();
while(i<n)
{
m.clear();
type = l[0].size()<l[1].size();
for(j=0;j<l[type].size()&&i<n;j++)
{
m.push_back(i);
i++;
m.push_back(l[type][j]);
}
int z = use_machine(m);
l[(z&1)^type].push_back(m[0]);
z = z/2+z%2;
if(type==1)ans+=z;
else
ans+=(i-m[0]-z);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |