Submission #631059

#TimeUsernameProblemLanguageResultExecution timeMemory
631059kingmosheRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
//#include "insects.h"
#include <vector>

/*void move_inside(int i) {

}*/
/*void move_outside(int i) {

}*/
/*int press_button() {

}*/
std::vector<bool> visited(0);
void init(int N) {
	visited.resize(N, false);
}
int get_number_of_types(int N) {
	move_inside(0);
	int counter = 0;
	visited[0] = true;
	for (int i = 1; i < N; i++) {
		move_inside(i);
		int value = press_button();
		if (value == 1) {
			visited[i] = true;
			counter += 1;
		}
		else {
			move_outside(i);
		}
	}
	return counter;
}
void remove_all_indexes(std::vector<int> indexes) {
	for (int i = 0; i < indexes.size(); i++) {
		move_outside(indexes[i]);
	}
}
int first_solution(int N) {
	int number_of_types = get_number_of_types(N);
	int current_result = 1;
	std::vector<int> inside_indexes(0);
	bool any_change = true;
	while (any_change) {
		for (int i = 0; i < N; i++) {
			if (visited[i]) {
				continue;
			}
			move_inside(i);
			int value = press_button();
			if (value > current_result + 1) {
				move_outside(i);
			}
			else {
				visited[i] = true;
				inside_indexes.push_back(i);
			}
			if (inside_indexes.size() == number_of_types) {
				any_change = true;
				counter_inside = 0;
				remove_all_indexes(inside_indexes);
			}
		}
		remove_all_indexes(inside_indexes);
		inside_indexes.resize(0);
	}
	return current_result;
}
int min_cardinality(int N) {
	init(N);
	return first_solution(N);
}

Compilation message (stderr)

insects.cpp: In function 'int get_number_of_types(int)':
insects.cpp:18:2: error: 'move_inside' was not declared in this scope
   18 |  move_inside(0);
      |  ^~~~~~~~~~~
insects.cpp:23:15: error: 'press_button' was not declared in this scope
   23 |   int value = press_button();
      |               ^~~~~~~~~~~~
insects.cpp:29:4: error: 'move_outside' was not declared in this scope
   29 |    move_outside(i);
      |    ^~~~~~~~~~~~
insects.cpp: In function 'void remove_all_indexes(std::vector<int>)':
insects.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i = 0; i < indexes.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~
insects.cpp:36:3: error: 'move_outside' was not declared in this scope
   36 |   move_outside(indexes[i]);
      |   ^~~~~~~~~~~~
insects.cpp: In function 'int first_solution(int)':
insects.cpp:49:4: error: 'move_inside' was not declared in this scope
   49 |    move_inside(i);
      |    ^~~~~~~~~~~
insects.cpp:50:16: error: 'press_button' was not declared in this scope
   50 |    int value = press_button();
      |                ^~~~~~~~~~~~
insects.cpp:52:5: error: 'move_outside' was not declared in this scope
   52 |     move_outside(i);
      |     ^~~~~~~~~~~~
insects.cpp:58:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |    if (inside_indexes.size() == number_of_types) {
      |        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
insects.cpp:60:5: error: 'counter_inside' was not declared in this scope
   60 |     counter_inside = 0;
      |     ^~~~~~~~~~~~~~