Submission #791132

#TimeUsernameProblemLanguageResultExecution timeMemory
791132Pablo_NoCounting Mushrooms (IOI20_mushrooms)C++17
Compilation error
0 ms0 KiB
using namespace std;

int count_mushrooms(int n) {
	std::vector<int> m;
	if(n == 2)
	{
		m = {0, 1};
		return 2-use_machine(m);
	}
	m = { 0, 1, };
	int a = use_machine(m);
	m = { 0, 2, };
	int b = use_machine(m);
	bool usingb = false;
	vector<int> hep;
	int ans = 1 + (1-a) + (1-b);
	if(a == 0)
	{
		hep = { 0, 1 };
	}
	else if(b == 0)
	{
		hep = { 0, 2 };
	}
	else
	{
		hep = { 1, 2 };
		usingb = true;
	}

	for(int i = 3; i+1 < n; i += 2)
	{
		m = { hep[0], i, hep[1], i+1 };
		int def = use_machine(m);
		def = def%2 + def/2;
		if(!usingb)
			def = 2-def;
		ans += def;
	}
	if(n%2 != 1)
	{
		m = { 0, n-1 };
		int e = use_machine(m);
		ans += (1-e);
	}
	return ans;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:4:7: error: 'vector' is not a member of 'std'
    4 |  std::vector<int> m;
      |       ^~~~~~
mushrooms.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | using namespace std;
mushrooms.cpp:4:14: error: expected primary-expression before 'int'
    4 |  std::vector<int> m;
      |              ^~~
mushrooms.cpp:7:3: error: 'm' was not declared in this scope
    7 |   m = {0, 1};
      |   ^
mushrooms.cpp:8:12: error: 'use_machine' was not declared in this scope
    8 |   return 2-use_machine(m);
      |            ^~~~~~~~~~~
mushrooms.cpp:10:2: error: 'm' was not declared in this scope
   10 |  m = { 0, 1, };
      |  ^
mushrooms.cpp:11:10: error: 'use_machine' was not declared in this scope
   11 |  int a = use_machine(m);
      |          ^~~~~~~~~~~
mushrooms.cpp:15:2: error: 'vector' was not declared in this scope
   15 |  vector<int> hep;
      |  ^~~~~~
mushrooms.cpp:15:2: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
mushrooms.cpp:15:9: error: expected primary-expression before 'int'
   15 |  vector<int> hep;
      |         ^~~
mushrooms.cpp:19:3: error: 'hep' was not declared in this scope
   19 |   hep = { 0, 1 };
      |   ^~~
mushrooms.cpp:23:3: error: 'hep' was not declared in this scope
   23 |   hep = { 0, 2 };
      |   ^~~
mushrooms.cpp:27:3: error: 'hep' was not declared in this scope
   27 |   hep = { 1, 2 };
      |   ^~~
mushrooms.cpp:33:9: error: 'hep' was not declared in this scope
   33 |   m = { hep[0], i, hep[1], i+1 };
      |         ^~~