Submission #458001

#TimeUsernameProblemLanguageResultExecution timeMemory
458001rainboyCounting Mushrooms (IOI20_mushrooms)C++17
56.93 / 100
13 ms328 KiB
#include "mushrooms.h"
#include <iostream>

using namespace std;

typedef vector<int> vi;

const int N = 100;

int aa[N], bb[N];

int count_mushrooms(int n) {
	vi ii;
	int na, nb, h, i, ans;

	na = nb = 0;
	aa[na++] = 0;
	for (i = 1; i < n && na < N && nb < N; i++) {
		ii.resize(2);
		ii[0] = 0, ii[1] = i;
		if (use_machine(ii) == 0)
			aa[na++] = i;
		else
			bb[nb++] = i;
	}
	if (i == n)
		return na;
	if (na == N) {
		ans = n - nb;
		while (i < n) {
			ii.resize(0);
			for (h = 0; h < na; h++) {
				ii.push_back(aa[h]);
				if (i < n)
					ii.push_back(i++);
			}
			ans -= (use_machine(ii) + 1) / 2;
		}
	} else {
		ans = na;
		while (i < n) {
			ii.resize(0);
			for (h = 0; h < nb; h++) {
				ii.push_back(bb[h]);
				if (i < n)
					ii.push_back(i++);
			}
			ans += (use_machine(ii) + 1) / 2;
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...