Submission #305724

# Submission time Handle Problem Language Result Execution time Memory
305724 2020-09-23T21:49:46 Z arthurconmy Counting Mushrooms (IOI20_mushrooms) C++14
Compilation error
0 ms 0 KB
#ifndef ARTHUR_LOCAL
	#include "mushrooms.h"
#endif

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

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;
	}
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:27:14: error: 'len' was not declared in this scope
   27 |  int no_As = len(As);
      |              ^~~
mushrooms.cpp:11:14: warning: control reaches end of non-void function [-Wreturn-type]
   11 |  vector<int> indices;
      |              ^~~~~~~