Submission #221223

# Submission time Handle Problem Language Result Execution time Memory
221223 2020-04-09T17:15:52 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);
		for (int i = 0; i < W; i++) {
			positions[i] += W;
		}
	}
	positions.erase(positions.begin(), positions.end());

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

	// H rows + W cols
	positions.erase(positions.begin(), positions.end());
	// all pairs distance 1
	// all pairs distance 2
	// 1 pair distance H-1
	positions.push_back(0);
	positions.push_back(0);

	int end_pos_x = H*W + H + W;

	vector<int> positions_rows;
	vector<int> positions_cols;

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

			add_and(positions);
			end_pos_x++;
		}
	}

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

			add_and(positions);
			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;

	vector<int> positions2;

	for (int j = 1; j < K; j++) {
		// j in H, (K-j) in W
		positions.erase(positions.begin(), positions.end());
		int options_y = H - j;
		int options_x = W - (K - j);
		int position_y = positions_rows(j - 1);
		int position_x = positions_cols(K - j - 1);

		if ((options_y > 0) && (options_x > 0)) {
			for (int i = 0; i < options_y; i++) {
				positions.push_back(position_y++);
			}
			add_or(positions);
			positions.erase(positions.begin(), positions.end());

			for (int i = 0; i < options_x; i++) {
				positions.push_back(position_x++);
			}
			add_or(positions);
			positions.erase(positions.begin(), positions.end());

			positions.push_back(start_pos_res);
			positions.push_back(start_pos_res + 1);
			add_and(positions);

			positions2.push_back(start_pos_res + 2);
			start_pos_res += 3;
		}
	}
	// 0-K and K-0
	for (int j = 0; j < H - K; j++) {
		positions.erase(positions.begin(), positions.end());
		positions.push_back(H*W + j);
		positions.push_back(H*W + j + K);
		add_and(positions);
		positions2.push_back(start_pos_res++);
	}
	for (int j = 0; j < W - K; j++) {
		positions.erase(positions.begin(), positions.end());
		positions.push_back(H*W + H + j);
		positions.push_back(H*W + H + j + K);
		add_and(positions);
		positions2.push_back(start_pos_res++);
	}

	add_or(positions2);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:76:40: error: no match for call to '(std::vector<int>) (int)'
   int position_y = positions_rows(j - 1);
                                        ^
vision.cpp:77:44: error: no match for call to '(std::vector<int>) (int)'
   int position_x = positions_cols(K - j - 1);
                                            ^
vision.cpp:64:6: warning: unused variable 'start_pos_y' [-Wunused-variable]
  int start_pos_y = H*W + H + W;
      ^~~~~~~~~~~
vision.cpp:67:6: warning: unused variable 'start_pos_ands' [-Wunused-variable]
  int start_pos_ands = start_pos_res;
      ^~~~~~~~~~~~~~