Submission #306629

#TimeUsernameProblemLanguageResultExecution timeMemory
306629daniel920712Counting Mushrooms (IOI20_mushrooms)C++14
0 / 100
0 ms256 KiB
#include "mushrooms.h"
#include <vector>
#include <math.h>
using namespace std;
vector < int > A,B;
vector < int > temp;
vector < int > fin;
int count_mushrooms(int N)
{
    int k=floor(sqrt(N)),ans=0,x=0,y=0,i,now,tt;
    for(i=1;i<=N-1;i+=2)
    {
        temp.clear();
        temp.push_back(0);
        temp.push_back(i);
        if(i+1<=N-1)
        {
            temp.push_back(i+1);
            tt=use_machine(temp);
            if(tt==0)
            {
                A.push_back(i);
                A.push_back(i+1);
                y+=2;
                ans+=2;
            }
            else if(tt==2)
            {
                A.push_back(i+1);
                B.push_back(i);
                x++;
                y++;
                ans++;
            }
            else
            {
                B.push_back(i+1);
                x++;
                fin.push_back(i);
                fin.push_back(i+1);
            }
        }
        else
        {
            if(use_machine(temp))
            {
                x++;
                B.push_back(i);
            }
            else
            {
                y++;
                A.push_back(i);
            }
        }

    }
    if(!fin.empty()) ans+=(use_machine(fin)+1)/2;
    /*if(x>=y)
    {
        now=k+1;
        while(now<N)
        {
            temp.clear();
            for(auto i:B)
            {
                temp.push_back(i);
                if(now<N)
                {
                    temp.push_back(now);
                    now++;
                }
            }

            if(temp.size()>=2)
            {
                tt=use_machine(temp);
                ans+=(tt+1)/2;
            }
            //if(tt%2==0) B.push_back(*prev(temp.end()));
        }

    }
    else
    {
        now=k+1;
        while(now<N)
        {
            temp.clear();
            for(auto i:A)
            {
                temp.push_back(i);
                if(now<N)
                {
                    temp.push_back(now);
                    now++;
                }
            }
            if(temp.size()>=2)
            {
                tt=use_machine(temp);
                ans+=(temp.size()-y-(tt+1)/2);
            }
        }
    }
    //ans+=y;*/
	return ans+1;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:10:9: warning: unused variable 'k' [-Wunused-variable]
   10 |     int k=floor(sqrt(N)),ans=0,x=0,y=0,i,now,tt;
      |         ^
mushrooms.cpp:10:42: warning: unused variable 'now' [-Wunused-variable]
   10 |     int k=floor(sqrt(N)),ans=0,x=0,y=0,i,now,tt;
      |                                          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...