Submission #1234036

#TimeUsernameProblemLanguageResultExecution timeMemory
1234036madamadam3Counting Mushrooms (IOI20_mushrooms)C++20
25 / 100
26 ms420 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
	#define dbg(x) (cout << (x))
#else
	#define dbg(x)
#endif

using vi =vector<int>;
#define pb push_back
#define FOR(i, a, b) for (int i = a; i < b; i++)

int count_mushrooms(int n) {
	vi isa(n, 0); isa[0] = 1;

	for (int i = 1; i < n; i += 2) {
		if (i == n - 1) {
			isa[i] = 1 - use_machine(vi({0, i}));
		} else {
			int tl = 2 - use_machine(vi({i, 0, i+1}));
			if (tl >= 1) isa[i] = 1;
			if (tl >= 2) isa[i+1] = 1;
		}
	}

	return accumulate(isa.begin(), isa.end(), 0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...