Submission #221194

# Submission time Handle Problem Language Result Execution time Memory
221194 2020-04-09T16:42:31 Z galca Vision Program (IOI19_vision) C++14
Compilation error
0 ms 0 KB
#include <vision.h>
#include <vector>
using namespace std;

void construct_network(int H, int W, int K) {
	vector<int> positions;
	
	for (int i = 0; i < W; i++) {
		positions.push_back(i);
	}
	for (int j = 0; j < H; j++) {
		add_xor(&positions[0]);
		for (int i = 0; i < W; i++) {
			position[i] += W;
		}
	}
	positions.erase(position.begin(), positions.end());

	for (int i = 0; i < H; i++) {
		positions[i] = i*W;
	}
	for (int j = 0; j < W; j++) {
		add_xor(&positions[0]);
		for (int i = 0; i < H; i++) {
			position[i] += 1;
		}
	}

	// H rows + W cols
	positions.erase(position.begin(), positions.end());
	// all pairs distance 1
	// all pairs distance 2
	// 1 pair distance H-1
	position[0] = 0;
	position[1] = 0;
	int end_pos_x = H*W + H + W;

	for (int j = 1; j < H; j++) {
		for (int i = 0; i < H - j; i++) {
			positions[0] = H*W + i;
			positions[1] = H*W + i + j;

			add_and(&positions[0]);
			end_pos_x++;
		}
	}

	for (int j = 1; j < W; j++) {
		for (int i = 0; i < W - j; i++) {
			positions[0] = H*W + H + i;
			positions[1] = H*W + H + i + j;

			add_and(&positions[0]);
			end_pos_x++;
		}
	}

	int start_pos_y = H*W + H + W;

	int start_pos_res = end_pos_x;
	int start_pos_ands = start_pos_res;

	for (int j = 1; j < K; j++) {
		// j in H, (K-j) in W
		positions.erase(position.begin(), positions.end());
		int options_y = H - j;
		for (int i = 0; i < options_y; i++) {
			positions.push_back(start_pos_y++);
		}
		add_or(&positions[0]);
		positions.erase(position.begin(), positions.end());
		int options_x = W - (K - j);
		for (int i = 0; i < options_y; i++) {
			positions.push_back(--end_pos_x);
		}
		add_or(&positions[0]);
		positions.erase(position.begin(), positions.end());
		positions[0] = start_pos_res;
		positions[1] = start_pos_res + 1;
		add_and(&positions[0]);
		start_pos_res += 3;
	}
	// 0-K and K-0
	for (int j = 0; j < H - K; j++) {
		positions.erase(position.begin(), positions.end());
		positions[0] = H*W + j;
		positions[1] = H*W + j + K;
		add_and(&positions[0]);
	}
	for (int j = 0; j < W - K; j++) {
		positions.erase(position.begin(), positions.end());
		positions[0] = H*W + H + j;
		positions[1] = H*W + H + j + K;
		add_and(&positions[0]);
	}
	positions.erase(position.begin(), positions.end());
	for (int j = 1; j < K; j++) {
		positions.push_back(start_pos_ands + 2);
		start_pos_ands += 3;
	}
	for (int j = 0; j < H - K; j++) {
		positions.push_back(start_pos_ands++);
	}
	for (int j = 0; j < W - K; j++) {
		positions.push_back(start_pos_ands++);
	}
	add_or(&positions[0]);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:12:11: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_xor(&positions[0]);
vision.cpp:14:4: error: 'position' was not declared in this scope
    position[i] += W;
    ^~~~~~~~
vision.cpp:14:4: note: suggested alternative: 'positions'
    position[i] += W;
    ^~~~~~~~
    positions
vision.cpp:17:18: error: 'position' was not declared in this scope
  positions.erase(position.begin(), positions.end());
                  ^~~~~~~~
vision.cpp:17:18: note: suggested alternative: 'positions'
  positions.erase(position.begin(), positions.end());
                  ^~~~~~~~
                  positions
vision.cpp:23:11: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_xor(&positions[0]);
vision.cpp:43:12: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
    add_and(&positions[0]);
vision.cpp:53:12: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
    add_and(&positions[0]);
vision.cpp:70:10: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_or(&positions[0]);
vision.cpp:76:10: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_or(&positions[0]);
vision.cpp:80:11: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_and(&positions[0]);
vision.cpp:72:7: warning: unused variable 'options_x' [-Wunused-variable]
   int options_x = W - (K - j);
       ^~~~~~~~~
vision.cpp:88:11: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_and(&positions[0]);
vision.cpp:94:11: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
   add_and(&positions[0]);
vision.cpp:107:9: error: could not convert '& positions.std::vector<int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type* {aka int*}' to 'std::vector<int>'
  add_or(&positions[0]);