| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1073726 | thatsgonzalez | Counting Mushrooms (IOI20_mushrooms) | C++14 | 1 ms | 344 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"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int count_mushrooms(int n) {
	int ans = 1;
	vector<int> a; a.pb(0);
	vector<int> b; 
	int res = use_machine({0,1,2});
	/*
	
		ABB
		ABA
		AAB
		AAA
	*/
	if(res == 0){
		a.pb(1); a.pb(2);
	}
	else if(res == 2){
		a.pb(2); b.pb(1);
	}
	else{
		res = use_machine({0,1});
		if(res){
			b.pb(1); b.pb(2);
		}
		else{
			a.pb(1); b.pb(2);
		}
	}
	int ind = 3;
	while(ind<n){
		vector <int> q; int how = 0;
		if(a.size()>b.size()){
			for(int i = 0; i<a.size() and ind<n; i++){
				q.pb(ind); q.pb(a[i]); ind++; how++;
			}
			res = use_machine(q);
			if(res&1){
				b.pb(ind);
			}
			else a.pb(ind);
			ans += how-(res)/2;
		}
		else{
			for(int i = 0; i<b.size() and ind<n; i++){
				q.pb(ind); q.pb(b[i]); ind++; how++;
			}
			res = use_machine(q);
			if(res&1) a.pb(ind);
			else b.pb(ind);
			ans += res/2 + (res&1);
		}	
	}
	return ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
