# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
221265 | 2020-04-09T18:59:59 Z | galca | Vision Program (IOI19_vision) | C++14 | 0 ms | 0 KB |
#include <vision.h> #include <vector> using namespace std; void construct_network(int H, int W, int K) { vector<int> positions; vector<int> positions2; positions2.push_back(0); positions2.push_back(0); 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; } } vector<int> positions_final_or; // starting from W*H + H + W, put xor of all positions positions.erase(positions.begin(), positions.end()); for (int i = 0; i < H; i++) { positions.push_back(W*H + i); add_xor(positions); } positions.erase(positions.begin(), positions.end()); for (int i = 0; i < W; i++) { positions.push_back(W*H + H + i); add_xor(positions); } for (int j = 1; j < K; j++) { int options_y = H - j; int options_x = W - (K - j); if ((options_y > 0) && (options_x > 0)) { vector<int> positions_or_y; vector<int> positions_or_x; //for (int i = 0; i < options_y; i++) { vector<int> positions_and; for (int k = 0; k < j; k++) { positions_and.push_back(H*W + H + W + k); //+i); } positions_or_y.push_back(add_and(positions_and)); //} positions2[0]=add_or(positions_or_y); //for (int i = 0; i < options_x; i++) { vector<int> positions_and; for (int k = 0; k < (K - j); k++) { positions_and.push_back(H*W + H + W + H + k); //+i); } positions_or_x.push_back(add_and(positions_and)); //} positions2[1] = add_or(positions_or_x); positions_final_or.push_back(add_and(positions2)); } } positions2.push_back(0); positions.erase(positions.begin(), positions.end()); for (int i = 0; i < W; i++) { positions.push_back(H*W + H + i); } int pos1 = add_not(add_or(positions)); positions.erase(positions.begin(), positions.end()); for (int i = 0; i < H; i++) { positions.push_back(H*W + i); } int pos2 = add_not(add_or(positions)); // 0-K and K-0 for (int j = 0; j < H - K; j++) { positions2[0] = H*W + j; positions2[1] = H*W + j + K; positions2[2] = pos1; positions_final_or.push_back(add_and(positions2)); } for (int j = 0; j < W - K; j++) { positions2[0] = H*W + H + j; positions2[1] = H*W + H + j + K; positions2[2] = pos2; positions_final_or.push_back(add_and(positions2)); } add_or(positions_final_or); }