Submission #307388

# Submission time Handle Problem Language Result Execution time Memory
307388 2020-09-28T03:55:13 Z arthur_nascimento Counting Mushrooms (IOI20_mushrooms) C++14
0 / 100
1 ms 256 KB
#include "mushrooms.h"
#define pb push_back
using namespace std;

const int C = 99;

int count_mushrooms(int n) {
	vector<int> A,B;
	A.pb(0);

	for(int i=1;i<min(3,n);i++){
		vector<int> v;
		v.pb(0);
		v.pb(i);
		int x = use_machine(v);
		if(x) B.pb(i);
		else A.pb(i);
	}

	int nx = 0;
	for(int i=3;i<min(C,n-2);i+=2){
		if(A.size() > B.size()){
			vector<int> v = {A[0],i,A[1],i+1};
			int x = use_machine(v);
			if(x >= 2)
				B.pb(i);
			else
				A.pb(i);
			if(x%2 == 1)
				B.pb(i+1);
			else
				A.pb(i+1);
		}	
		else {
			vector<int> v = {B[0],i,B[1],i+1};
			int x = use_machine(v);
			if(x >= 2)
				A.pb(i);
			else
				B.pb(i);
			if(x%2 == 1)
				A.pb(i+1);
			else
				B.pb(i+1);
		}
		nx = i+2;
	}


	int ans = A.size();

	int eff = 0;
	for(int i=nx;i<n;){

		int t = max(A.size(), B.size());
		int use = 0;
		if(B.size() > A.size()) use = 1;

		vector<int> vec = A;
		if(use) vec = B;
	
		vector<int> v;
		eff = 0;
		for(int j=0;j<t;j++){
			v.pb(vec[j]);
			if(j < t-1 && i+j < n) v.pb(i+j), eff++;
		}
		int x = use_machine(v);
		//printf("ff %d\n",eff);
		if(use) ans += x/2;
		else ans += eff - (x/2);

		i += t-1;
		
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Duplicate value 1 in the query array.
2 Halted 0 ms 0 KB -