Submission #1233566

#TimeUsernameProblemLanguageResultExecution timeMemory
1233566colossal_pepeCounting Mushrooms (IOI20_mushrooms)C++20
25 / 100
27 ms420 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;

int count_mushrooms(int n) {
	int A0 = 0, B0 = -1, A1 = -1, B1 = -1;
	int i = 1;
	while (i < n and A1 == -1 and B1 == -1) {
		int c = use_machine(vector<int>{A0, i});
		if (c) {
			if (B0 == -1) B0 = i;
			else B1 = i;
		} else A1 = i;
		i++;
	}
	int cnt = 1 + (A1 != -1);
	while (i < n - 1) {
		if (A1 != -1) {
			int c = use_machine(vector<int>{A0, i, A1, i + 1});
			if (c == 0) cnt += 2;
			else if (c == 1 or c == 2) cnt += 1;
		} else if (B1 != -1) {
			int c = use_machine(vector<int>{B0, i, B1, i + 1});
			if (c == 3) cnt += 2;
			else if (c == 1 or c == 2) cnt += 1;
		}
		i += 2;
	}
	if (i < n) cnt += !use_machine(vector<int>{A0, i});
	return cnt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...