# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780828 | teamariaa | Counting Mushrooms (IOI20_mushrooms) | C++17 | 2 ms | 304 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 <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
#define pb push_back
int count_mushrooms(int n)
{
vector <int> m, aPos, bPos;
int ans, cnt, flag = 0;
int capat = min(200, n);
aPos.pb(0);
// cout << capat << "\n";
for(int i = 1; i < capat; i ++)
{
// cout << "a\n";
m = {0, i};
ans = use_machine(m);
if(ans)
bPos.pb(i);
else
aPos.pb(i);
}
// cout << "fsfsd " << bPos.size() << "\n";
if(n < 200)
return aPos.size();
int len;
if(aPos.size() > bPos.size())
{
m.resize(2 * aPos.size());
for(int i = 0; i < aPos.size(); i ++)
m[2 * i] = aPos[i];
len = aPos.size();
}
else
{
m.resize(2 * bPos.size());
flag = 1;
for(int i = 0; i < bPos.size(); i ++)
m[2 * i] = bPos[i];
len = bPos.size();
}
cnt += aPos.size();
int i = 200;
while(i < n)
{
int k = 0;
while(i < n && k < len)
{
m[2 * k + 1] = i;
i ++;
k ++;
}
if(i == n && k < len)
m.resize(2 * k);
ans = use_machine(m);
if(flag)
{
cnt += (ans + 1) / 2;
}
else
{
int bNo = (ans + 1) / 2;
cnt += len - bNo;
}
}
return cnt;
// for(int i = 0; i < (n - 200) / len; i ++)
// {
// for(int j = 200 + i * len; j < 200 + (i + 1) * len; j ++)
// {
// m[2 * j + 1] = j;
// }
//
// ans = use_machine(m);
// if(flag)
// {
// cnt += (ans + 1) / 2;
// }
// else
// {
// int bNo = (ans + 1) / 2;
// cnt += len - bNo;
// }
// }
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |