Submission #221481

#TimeUsernameProblemLanguageResultExecution timeMemory
221481galcaMechanical Doll (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include "doll.h" // N + 1 = 15 // num_bits = 4 // we should have: 1 + 2 + 4 + 8 void create_circuit(int M, std::vector<int> A) { int N = A.size(); std::vector<int> C(M + 1); for (int i = 0; i <= M; ++i) { C[i] = -1; } std::vector<int> X, Y; int num_bits = 0; int tmp = N + 1; while (tmp > 0) { ++num_bits; tmp >>= 1; } for (int k = 1; k < num_bits; ++k) { int n_nodes = 1 << (k-1); for (int n = 0; n < n_nodes; n++) { X.push_back(-n * 2); Y.push_back(-(n * 2 + 1)); } } // N nodes of the last level are connected to the triggers, the last one // 2^bits-N-1 to -1 // and the last one to origin int n_leaves = 1 << (num_bits-1); int idx_b = X.size(); for (int n = 0; n < n_leaves; n++) { X.push_back(-1); Y.push_back(-1); } for (int n = 0; n < N; n++) { // revert the number int offset = n_leaves; int n_tmp = n; int n_pos = 0; while (n_tmp > 0) { if (n_tmp & 1) { n_pos += offset; } n_tmp >>= 1; offset >>= 1; } if (n_pos & 1) { Y[idx_b + n_inv/2] = A[n]; } else { X[idx_b + n_inv/2] = A[n]; } } Y[Y.size()-1] = 0; answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:57:14: error: 'n_inv' was not declared in this scope
   57 |    Y[idx_b + n_inv/2] = A[n];
      |              ^~~~~
doll.cpp:60:14: error: 'n_inv' was not declared in this scope
   60 |    X[idx_b + n_inv/2] = A[n];
      |              ^~~~~