| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1023036 | TheWilp | Counting Mushrooms (IOI20_mushrooms) | C++14 | 8 ms | 712 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mushrooms.h"
int count_mushrooms(int n) {
	if(n == 1) return 1;
	std::vector<int> A;
	std::vector<int> B;
	A.push_back(0);
	int ans = 0;
	int i = 1;
	while(i < n) {
		bool Abase = B.size() <= A.size();
		std::vector<int>* in = Abase ? &A : &B;
		std::vector<int> v;
		if(in->size() >= 2 && in->size() < 84) {
			v.push_back((*in)[0]);
			v.push_back(i++);
			v.push_back((*in)[1]);
			bool back_push = i < n;
			if(back_push) v.push_back(i++);
			int count = use_machine(v);
			if(Abase) {
				if(back_push) {
					if(count%2) B.push_back(v.back());
					else A.push_back(v.back());
				}
				if(count > 1) B.push_back(v[1]);
				else A.push_back(v[1]);
			}
			else {
				if(back_push) {
					if(count%2) A.push_back(v.back());
					else B.push_back(v.back());
				}
				if(count > 1) A.push_back(v[1]);
				else B.push_back(v[1]);
			}
		}
		else {
			int c = 1;
			v.push_back((*in)[0]);
			while(i < n) {
				if(c < in->size()) {
					v.push_back(i++);
					v.push_back((*in)[c++]);
				}
				else {
					break;
				}
			}
			bool pos_push = false;
			if(i < n) v.push_back(i++),pos_push = true;
			int count = use_machine(v);
			if(Abase) {
				ans += (v.size() + 1) / 2 - 1 - count / 2;
				if(pos_push) 
					if(count%2) B.push_back(v.back());
					else A.push_back(v.back());
			}
			else {
				ans += count / 2;
				if(pos_push) 
					if(count%2) A.push_back(v.back());
					else B.push_back(v.back());
			}
		}
	}
	return ans + A.size();
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
