Submission #1054826

# Submission time Handle Problem Language Result Execution time Memory
1054826 2024-08-12T12:27:34 Z Gromp15 Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
9 ms 604 KB
#include <bits/stdc++.h>
#include "mushrooms.h"
#define sz(x) (int)x.size()
using namespace std;

const int len = 115;

int count_mushrooms(int n) {
	for (int i = 0; i < 5; i++) {
		vector<int> tmp(n);
		iota(tmp.begin(), tmp.end(), 0);
		shuffle(tmp.begin(), tmp.end(), mt19937(std::chrono::steady_clock::now().time_since_epoch().count()));
		use_machine(tmp);
	}
	vector<int> A{0}, B;
	vector<int> idx(n-1);
	iota(idx.begin(), idx.end(), 1);
	shuffle(idx.begin(), idx.end(), mt19937(2134321));
	idx.insert(idx.begin(), -1);
	for (int i = 1; i < min(n, len * 2); i++) {
		if (i+1 < min(n, len * 2)) {
			int res = use_machine({idx[i], 0, idx[i+1]});
			if (res == 0) {
				A.push_back(idx[i]);
				A.push_back(idx[i+1]);
			}
			else if (res == 2) {
				B.push_back(idx[i]);
				B.push_back(idx[i+1]);
			}
			else {
				int res = use_machine({0, idx[i]});
				if (res == 0) A.push_back(idx[i]), B.push_back(idx[i+1]);
				else A.push_back(idx[i+1]), B.push_back(idx[i]);
			}
			i++;
		}
		else {
			(use_machine({0, idx[i]}) ? B : A).push_back(idx[i]);
		}
	}
	int ans = A.size();
	bool inv = 0;
	if (A.size() < B.size()) swap(A, B), inv = 1;
	/*
	for (int x : A) cout << x << " ";
	cout << '\n';
	for (int x : B) cout << x << " ";
	cout << '\n';
	*/
	vector<int> cur{A[0]};
	for (int j = len * 2, on = 1; j < n; j++) {
		if (on == sz(A)) {
			int res = use_machine(cur);
			ans += inv ? res / 2 : sz(cur) - sz(A) - res / 2;
			cur.clear();
			cur.emplace_back(A[0]);
			on = 1;
		}
		cur.emplace_back(idx[j]);
		cur.emplace_back(A[on++]);
	}
	//cout << "LST " << cur.size()<< '\n';
	if (cur.size() > 1) {
		int res = use_machine(cur);
		//cout << "R " << res << " " << ans << '\n';
		ans += inv ? res / 2 : sz(cur) / 2 - res / 2;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 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 344 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Incorrect 9 ms 604 KB Too many total array sizes as queries.
8 Halted 0 ms 0 KB -