Submission #411660

#TimeUsernameProblemLanguageResultExecution timeMemory
411660JUANDI321Counting Mushrooms (IOI20_mushrooms)C++17
25 / 100
146 ms200 KiB
#include "mushrooms.h"
#include <iostream>
#include <vector>
 
using namespace std;
vector<int> x;

int count_mushrooms(int n)
{
    long long A = 1;
    if(n%2 != 0)
    {
    	for(int i = 1; i<n; i+=2)
    	{
    		x.push_back(i);
    		x.push_back(0);
    		x.push_back(i+1);
    		int p = use_machine(x);
    		if(p == 0)A+=2;
    		if(p == 1)A++;
    		x.clear();
		}
	}
	else
	{
		for(int i = 1; i<n-1; i+=2)
    	{
    		x.push_back(i);
    		x.push_back(0);
    		x.push_back(i+1);
    		int p = use_machine(x);
    		if(p == 0)A+=2;
    		if(p == 1)A++;
    		x.clear();
		}
		x.push_back(0);
		x.push_back(n-1);
    	int p = use_machine(x);
    	if(p == 0)A++;
    	x.clear();
	}
    return A;
}
#Verdict Execution timeMemoryGrader output
Fetching results...