Submission #307397

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

const int C = 219;

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 ua = 1;
	if(B.size() > A.size()) ua = 0;
	
	int nx = 3;
	for(int i=3;i<min(C,n-2);i+=2){
		if(ua){
			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;
		int spec = -1;
		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++;
			if(j == t-1 && i+j < n){
				v.pb(i+j);
				spec = i+j;
			}	
		}
		int x = use_machine(v);
		//printf("ff %d\n",eff);
		if(use) ans += x/2;
		else ans += eff - (x/2);

		if(spec+1){
			if(x%2 == 1){
				B.pb(spec);
			}
			else {
				A.pb(spec);
				ans++;
			}
		}

		i += t-1;
		if(spec+1) i++;
		
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
8 Correct 8 ms 256 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Partially correct 7 ms 256 KB Output is partially correct
12 Incorrect 7 ms 256 KB Answer is not correct.
13 Halted 0 ms 0 KB -