Submission #1148675

#TimeUsernameProblemLanguageResultExecution timeMemory
1148675PagodePaivaCounting Mushrooms (IOI20_mushrooms)C++20
25 / 100
28 ms760 KiB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;

int count_mushrooms(int n) {
	vector <int> ask = {0};
	vector <int> fim;
	int ans = 1;
	for(int i = 1;i+1 < n;i += 2){
		ask.push_back(i);
		ask.push_back(i+1);
		int t = use_machine(ask);
		ask.clear();
		ask.push_back(0);
		if(t == 0) ans += 2;
		if(t == 2) ans += 1;
		if(t == 1){
			fim.push_back(i);
			fim.push_back(i+1);
		}
	}
	if(n%2 == 0){
		ask.push_back(n-1);
		int t = use_machine(ask);
		ans += (1-t);
	}
	if(fim.empty()) return ans;
	vector <int> aux;
	aux.push_back(0);
	aux.push_back(fim[0]);
	int valor = use_machine(aux);
	for(int i = 1;i < fim.size();i++)
		aux.push_back(fim[i]);
	int valor2 = use_machine(aux);
	if(valor == 0) valor2++;
	else valor2--;
	return ans + valor2/2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...