Submission #1297527

#TimeUsernameProblemLanguageResultExecution timeMemory
1297527kawhietCounting Mushrooms (IOI20_mushrooms)C++20
0 / 100
2 ms404 KiB
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;

int count_mushrooms(int n) {
	int res = 1;
	vector<int> a = {0}, b, s;
	for (int i = 1; i < n; i++) {
		s.push_back(i);
	}
	while (max(a.size(), b.size()) < 100 && !s.empty()) {
		int x = s.back();
		if (use_machine({0, x}) == 0) {
			res++;
			a.push_back(x);
		} else {
			b.push_back(x);
		}
		s.pop_back();
	}
	vector<int> k = (a.size() == 100 ? a : b);
	while (!s.empty()) {
		int m = min(100, (int)s.size());
		vector<int> t;
		for (int i = 0; i < m; i++) {
			t.push_back(k[i]);
			t.push_back(s.back());
			s.pop_back();
		}
		int cnt = use_machine(t);
		if (a.size() == 0) {
			res += m - (cnt + 1) / 2;
		} else {
			res += cnt;
		}
	}
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...