Submission #1298186

#TimeUsernameProblemLanguageResultExecution timeMemory
1298186orgiloogiiCounting Mushrooms (IOI20_mushrooms)C++20
Compilation error
0 ms0 KiB
#include "mushrooms.h"
//#include <bits/stdc++.h>
//#define int long long
//using namespace std;
//int count_mushrooms(int n) {
//	std::vector<int> m;
//	for (int i = 0; i < n; i++)
//		m.push_back(i);
//	int c1 = use_machine(m);
//	m = {0, 1};
//	int c2 = use_machine(m);
//	return c1+c2;
//}

int count_mushrooms(int n) {
//	vector <int> m;
	vector <int> as, bs;
	as.push_back(0);
	int i = 1;
	while (i < n && as.size() < 100 && bs.size() < 100) {
		if (use_machine({0, i}) == 1) {
			bs.push_back(i);
		}
		else {
			as.push_back(i);
		}
		i++;
	}
	if (i == n) {
		return as.size();
	}
	ans = as.size();
	if (bs.size() == 100) {
		while (i < n) {
			int j = i + 1;
			vector <int> m;
			while (j < n && j <= i + 100) {
				m.push_back(bs[j - i - 1]);
				m.push_back(j);
				j++;
			}
			int c = use_machine(m);
			if (c % 2 == 1) {
				ans += 1;
			}
			ans += c / 2;
			i = j;
		}
		return ans;
	}
	while (i < n) {
		int j = i + 1;
		int cnt = 0;
		vector <int> m;
		while (j < n && j <= i + 100) {
			m.push_back(as[j - i - 1]);
			m.push_back(j);
			j++;
			cnt++;
		}
		int c = use_machine(m);
		ans += cnt - (c / 2);
	}
	return ans;
	
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:17:9: error: 'vector' was not declared in this scope
   17 |         vector <int> as, bs;
      |         ^~~~~~
mushrooms.cpp:17:9: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66,
                 from mushrooms.h:1,
                 from mushrooms.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
mushrooms.cpp:17:17: error: expected primary-expression before 'int'
   17 |         vector <int> as, bs;
      |                 ^~~
mushrooms.cpp:18:9: error: 'as' was not declared in this scope
   18 |         as.push_back(0);
      |         ^~
mushrooms.cpp:20:44: error: 'bs' was not declared in this scope
   20 |         while (i < n && as.size() < 100 && bs.size() < 100) {
      |                                            ^~
mushrooms.cpp:32:9: error: 'ans' was not declared in this scope
   32 |         ans = as.size();
      |         ^~~
mushrooms.cpp:33:13: error: 'bs' was not declared in this scope
   33 |         if (bs.size() == 100) {
      |             ^~
mushrooms.cpp:36:33: error: expected primary-expression before 'int'
   36 |                         vector <int> m;
      |                                 ^~~
mushrooms.cpp:38:33: error: 'm' was not declared in this scope
   38 |                                 m.push_back(bs[j - i - 1]);
      |                                 ^
mushrooms.cpp:42:45: error: 'm' was not declared in this scope
   42 |                         int c = use_machine(m);
      |                                             ^
mushrooms.cpp:54:25: error: expected primary-expression before 'int'
   54 |                 vector <int> m;
      |                         ^~~
mushrooms.cpp:56:25: error: 'm' was not declared in this scope
   56 |                         m.push_back(as[j - i - 1]);
      |                         ^
mushrooms.cpp:61:37: error: 'm' was not declared in this scope
   61 |                 int c = use_machine(m);
      |                                     ^