Submission #1014842

# Submission time Handle Problem Language Result Execution time Memory
1014842 2024-07-05T15:40:36 Z Unforgettablepl Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

int use_machine(vector<int> x);

int count_mushrooms(int n) {
	vector<bool> type(n);
	{
		int t = use_machine({0,1});
		if(t==0)type[1]=false;
		else type[1]=true;
	}
	if(n>2){
		int t = use_machine({0,2});
		if(t==0)type[2]=false;
		else type[2]=true;
	} else {
		return 1 + type[1]==false;
	}
	int a,b;bool ty;
	if(type[0]==type[1]){
		a = 0;
		b = 1;
		ty = false;
	} else if(type[0]==type[2]){
		a = 0;
		b = 2;
		ty = false;
	} else {
		a = 1;
		b = 2;
		ty = true;
	}
	type.emplace_back(false);
	for(int i=3;i<n;i+=2){
		int curr;
		if(i==n-1){
			curr = use_machine({a,i,b});
		} else {
			curr = use_machine({a,i,b,i+1});
		}
		if(curr&1){
			type[i+1] = !ty;
		} else type[i] = ty;
		if(curr&2){
			type[i] = !ty;
		} else type[i] = ty;
	}
	int ans = 0;
	for(int i=0;i<n;i++)if(type[i]==false)ans++;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Answer is not correct.
4 Halted 0 ms 0 KB -