Submission #1297433

#TimeUsernameProblemLanguageResultExecution timeMemory
1297433kawhietCounting Mushrooms (IOI20_mushrooms)C++20
25 / 100
41 ms400 KiB
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;

int count_mushrooms(int n) {
	int res = 1, prv = 0;
	int j = -1;
	for (int i = 2; i < n; i += 2) {
		if (j == -1) {
			int x = use_machine({0, i - 1, i});
			if (x == 0) {
				j = i - 1;
				res += 2;
			} else if (x == 1) {
				if (use_machine({i - 1, i}) == 1) {
					j = i - 1;
					res++;
				}
			} else {
				j = i;
				res++;
			}
		} else {
			int x = use_machine({0, i - 1, j, i});
			if (x == 0) {
				res += 2;
			} else if (x == 1 || x == 2) {
				res++;
			}
		}
	}
	if (n % 2 == 0) {
		if (use_machine({0, n - 1}) == 0) {
			res++;
		}
	}
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...