Submission #475948

#TimeUsernameProblemLanguageResultExecution timeMemory
475948kessidoMechanical Doll (IOI18_doll)C++17
Compilation error
0 ms0 KiB
#include "doll.h" const int UNASSINED = 1'000'000'000; const int ROOT = 1'000'000'001; using vi = std::vector<int>; vi craete_level(const vi& last_level, vi& X, vi& Y, int& S) { vi new_level; for(size_t i = 0; i < last_level.size(); i++) { if(i+1 < last_level.size()) { X.push_back(last_level[i]); Y.push_back(last_level[i+1]); new_level.push_back(-1 * (++S)); } } return new_level; } int& simulate_untill_next_unassined(int cur_switch, vi& state, vi& X, vi& Y) { while(true) { int idx = -cur_switch - 1; int* ptr = state[idx] ? &X[idx] : &Y[idx]; int& val = *ptr; if(val == UNASSINED) return val; assert(val < 0); cur_switch = val; } } void create_circuit(int M, std::vector<int> A) { const int N = A.size(); // create tree with N leefs vi X, Y; vi last_level(N, UNASSINED); int S = 0; while(last_level.size() != 1) last_level = create_level(last_level, X, Y, S); int root = -S; for(int i = 0; i < S; i++) if(Y[i]==ROOT) Y[i] = root; vi C(M + 1, root); C[0] = A[0]; // first go to A0, and than everyone goes to root. vi state(-S); for(int i = 1; i < N; i++) { int& v = simulate_untill_next_unassined(root, state, X, Y); v = A[i]; } int& last_v = simulate_untill_next_unassined(root, state, X, Y); last_v = 0; for(int i : state) assert(i == 0); for(int i : X) assert(i != UNASSINED); for(int i : Y) assert(i != UNASSINED); assert(X.size() == -S); assert(Y.size() == -S); answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'int& simulate_untill_next_unassined(int, vi&, vi&, vi&)':
doll.cpp:25:5: error: 'assert' was not declared in this scope
   25 |     assert(val < 0);
      |     ^~~~~~
doll.cpp:2:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    1 | #include "doll.h"
  +++ |+#include <cassert>
    2 | const int UNASSINED = 1'000'000'000;
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:37:18: error: 'create_level' was not declared in this scope; did you mean 'craete_level'?
   37 |     last_level = create_level(last_level, X, Y, S);
      |                  ^~~~~~~~~~~~
      |                  craete_level
doll.cpp:53:22: error: 'assert' was not declared in this scope
   53 |   for(int i : state) assert(i == 0);
      |                      ^~~~~~
doll.cpp:53:22: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
doll.cpp:54:18: error: 'assert' was not declared in this scope
   54 |   for(int i : X) assert(i != UNASSINED);
      |                  ^~~~~~
doll.cpp:54:18: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
doll.cpp:55:18: error: 'assert' was not declared in this scope
   55 |   for(int i : Y) assert(i != UNASSINED);
      |                  ^~~~~~
doll.cpp:55:18: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
doll.cpp:56:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |   assert(X.size() == -S);
      |          ~~~~~~~~~^~~~~
doll.cpp:56:3: error: 'assert' was not declared in this scope
   56 |   assert(X.size() == -S);
      |   ^~~~~~
doll.cpp:56:3: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
doll.cpp:57:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |   assert(Y.size() == -S);
      |          ~~~~~~~~~^~~~~