Submission #579998

#TimeUsernameProblemLanguageResultExecution timeMemory
579998VanillaCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
const int block = 141;

int cd2 (int x) {
	return x / 2 + (x % 2);
}

int count_mushrooms(int n) {
	vector <int> s0 = {0}, s1;
	vector <int> prf = {0};
	int block = sqrt(n);
	int sf = 0;
	for (int i = 1; i < 2 * block; i++){
		prf.push_back(i);
		sf = use_machine(prf);
		((sf % 2) ? s1: s0).push_back(i);
	}
	bool rev = 0;
	int rs = s0.size();
	int oth = 0;
	if (s1.size() > s0.size()) {
		rev = 1;
		swap(s0, s1);
	}
	vector <int> idx;
	for (int i = block * 2; i < n; i++){
		idx.push_back(s0[i % block]);
		idx.push_back(i);
		if (i % block == block - 1 || i == n - 1) {
			oth+=cd2(use_machine(idx));
			idx.clear();
		}
	}
	cout << rs << " " << oth << "\n";
	if (!rev) oth = n - block * 2 - oth;
	return rs + oth;
}
#Verdict Execution timeMemoryGrader output
Fetching results...