Submission #305725

# Submission time Handle Problem Language Result Execution time Memory
305725 2020-09-23T21:50:18 Z arthurconmy Counting Mushrooms (IOI20_mushrooms) C++14
0 / 100
1 ms 256 KB
#ifndef ARTHUR_LOCAL
	#include "mushrooms.h"
#endif

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define len(x) int((x).size())

int count_mushrooms(int n) 
{
	vector<int> indices;
	for(int i=1; i<n; i++) indices.push_back(i);

	vector<int> As;
	vector<int> Bs;

	for(int i=1; i<=200 && !indices.empty(); i++)
	{
		int cur = use_machine({0,indices.back()});

		if(cur==1) Bs.push_back(indices.back());
		else As.push_back(indices.back());

		indices.pop_back();
	}

	int no_As = len(As);

	if(len(As)>=len(Bs))
	{
		// reverse(As.begin(),As.end());
		// As.push_back(0);
		// reverse(As.begin());

		while(!indices.empty())
		{
			vector<int> cur;

			while(!indices.empty() && len(cur) <= len(As))
			{
				cur.push_back(indices.back());
				indices.pop_back();
			}

			vector<int> req = {0};
		
			for(int i=0; i<len(cur); i++)
			{
				req.push_back(cur[i]);
				if(i<len(As)) req.push_back(As[i]);
			}

			int curbs = int((use_machine(req)+1)/2);
			no_As += len(cur) - curbs;
		}

		return no_As;
	}

	else
	{
		while(!indices.empty())
		{
			vector<int> cur;

			while(!indices.empty() && len(cur) < len(Bs))
			{
				cur.push_back(indices.back());
				indices.pop_back();
			}

			vector<int> req = {0};

			for(int i=0; i<len(cur); i++)
			{
				req.push_back(Bs[i]);
				req.push_back(cur[i]);
			}

			no_As += int((use_machine(req)+1)/2);
		}

		return no_As;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Answer is not correct.
2 Halted 0 ms 0 KB -