Submission #1192067

#TimeUsernameProblemLanguageResultExecution timeMemory
1192067alexddCounting Mushrooms (IOI20_mushrooms)C++20
0 / 100
6 ms460 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
const int LIM = 142;
int count_mushrooms(int n)
{
    vector<int> v[2];
    v[0].push_back(0);
    int ult=0;
    for(int i=1;i<n;i++)
    {
        v[0].push_back(i);
        if(use_machine(v[0])==0)
        {

        }
        else
        {
            v[0].pop_back();
            v[1].push_back(i);
        }
        ult = i;
        //if(max(v[0].size(), v[1].size()) >= LIM) break;
        if(v[1].size() >= LIM) break;
    }

    if(ult==n-1)
        return v[0].size();

    int cnt = v[0].size();
    if(v[1].size() >= LIM)
    {
        assert(v[1].size() >= LIM);
        for(int i=ult+1;i<n;i+=v[1].size())
        {
            vector<int> newv;
            for(int j=0;j<v[1].size();j++)
            {
                newv.push_back(v[1][j]);
                if(i+j < n) newv.push_back(i+j);
            }
            int x = use_machine(newv);
            cnt += (x+1)/2;
        }
    }
    else
    {
        assert(0);
        assert(v[0].size() >= LIM);
        for(int i=ult+1;i<n;i+=v[0].size())
        {
            vector<int> newv;
            for(int j=0;j<v[0].size();j++)
            {
                newv.push_back(v[0][j]);
                if(i+j < n) newv.push_back(i+j);
            }
            int x = use_machine(newv);
            cnt += (x+1)/2;
        }
    }

    return cnt;
}

#Verdict Execution timeMemoryGrader output
Fetching results...