Submission #830956

#TimeUsernameProblemLanguageResultExecution timeMemory
830956pavementCounting Mushrooms (IOI20_mushrooms)C++17
10 / 100
178 ms424 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

vector<bool> solve(int l, int r) {
	if (l == r) {
		return {0};
	}
	int m = (l + r) / 2;
	auto lh = solve(l, m), rh = solve(m + 1, r);
	bool diff = use_machine({m, m + 1}) ^ lh.back() ^ rh[0];
	for (auto i : rh) {
		lh.pb(i ^ diff);
	}
	return lh;
}

int count_mushrooms(int n) {
	auto seq = solve(0, n - 1);
	return count(seq.begin(), seq.end(), 0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...