Submission #959349

# Submission time Handle Problem Language Result Execution time Memory
959349 2024-04-08T05:20:49 Z The_Samurai Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
5 ms 600 KB
#include "mushrooms.h"
#include "bits/stdc++.h"
using namespace std;

int count_mushrooms(int n) {
	vector<int> zeros = {0};
	const int cnt = 30, block_size = 25;
	for (int l = 1, r = 1 + block_size; l < n and zeros.size() < cnt; l += block_size, r += block_size) {
		r = min(r, n - 1);
		vector<int> v = {0};
		for (int i = l; i <= r; i++) v.emplace_back(i);
		int x = use_machine(v);
		if (x == 0) {
			for (int i = l; i <= r; i++) v.emplace_back(i);
			continue;
		}
		if (x == 1) continue;
		for (int i = l; i <= r; i++) {
			if (use_machine({0, i}) == 0) zeros.emplace_back(i);
		}
	}
	if (zeros.size() < cnt) return zeros.size();
	vector<int> unused;
	for (int i = zeros.back() + 1; i < n; i++) unused.emplace_back(i);
	int ans = zeros.size();
	while (!unused.empty()) {
		int ln = min(unused.size(), zeros.size());
		vector<int> v;
		for (int i = 0; i < ln; i++) {
			v.emplace_back(zeros[i]);
			v.emplace_back(unused.back());
			unused.pop_back();
		}
		ans += ln - (use_machine(v) + 1) / 2;
	}
	return ans;
}

// 0 -> 3
// 2 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
6 Correct 2 ms 448 KB Output is correct
7 Incorrect 5 ms 600 KB Answer is not correct.
8 Halted 0 ms 0 KB -