Submission #1302773

#TimeUsernameProblemLanguageResultExecution timeMemory
1302773sanoCounting Mushrooms (IOI20_mushrooms)C++20
25 / 100
30 ms400 KiB
#include "mushrooms.h"
#include <iostream>
#include <set>
#define vec vector
#define For(i, n) for(int i = 0; i < n; i++)
using namespace std;

void vypis(vec<int>&x){
	for(auto i : x) cerr << i << ' ';
	cerr << endl;
	return;
}

int count_mushrooms(int n) {
	vec<int> odp(n, 0);
	vec<int> mo;
	vec<int> p(2, 0);
	mo = {0, 1};
	int x = use_machine(mo);
	if(n == 2){
		if(x == 0) return 2;
		return 1;
	}
	odp[1] = x;
	mo = {1, 2};
	x = use_machine(mo);
	if(x == 1) odp[2] = 1 - odp[1];
	else odp[2] = odp[1];
	int typ = 0;
	int p2 = 0;
	For(i, 3) if(odp[i] == 1) p2++;
	if(p2 > 1) typ = 1;
	mo.clear();
	cerr << "typ " << typ << endl;
	For(i, 3){
		if(odp[i] == typ && mo.size() < 2) mo.push_back(i);
	}
	vypis(mo);
	for (int i = 3; i < n; i+=2) {
		vec<int> nm;
		nm.push_back(mo[0]);
		nm.push_back(i);
		nm.push_back(mo[1]);
		if(i+1 < n) nm.push_back(i+1);
		x = use_machine(nm);
		if((i+1) < n){
			if((x % 2) == 1){
				odp[i+1] = 1 - typ;
			}
			else{
				odp[i+1] = typ;
			}
		}
		if(x > 1){
			odp[i] = 1 - typ;
		}
		else{
			odp[i] = typ;
		}
	}
	For(i, n){
		p[odp[i]]++;
	}
	return p[0];
}
#Verdict Execution timeMemoryGrader output
Fetching results...