Submission #1297511

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

int count_mushrooms(int n) {
	int res = 1;
	vector<int> x, a = {0};
	for (int i = 1; i < n; i++) {
		x.push_back(i);
	}
	while (!x.empty()) {
		int m = min(x.size(), a.size());
		vector<int> b, cur;
		for (int i = 0; i < m; i++) {
			b.push_back(a[i]);
			b.push_back(x.back());
			cur.push_back(x.back());
			x.pop_back();
		}
		int k = use_machine(b);
		res += m - (k + 1) / 2;
		if (k == 0) {
			a.insert(a.end(), cur.begin(), cur.end());
		} else {
			for (auto i : cur) {
				if (use_machine({0, i}) == 0) {
					a.push_back(i);
					k--;
					if (k == 0) break;
				}
			}
		}
	}
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...