Submission #95667

#TimeUsernameProblemLanguageResultExecution timeMemory
95667shenxyMechanical Doll (IOI18_doll)C++11
Compilation error
0 ms0 KiB
#include <algorithm> #include "doll.h" #include <vector> using namespace std; int num_bits_in(int N) { int ans = 0; while (N != 0) { ans += 1; N = N >> 1; } return ans; } void create_circuit(int M, vector<int> A) { if (M == 1) { int evilnum = A.size() - 1; vector<int> C(2); C[0] = 1; C[1] = -1; vector<int> X(num_bits_in(A.size() - 1), 1), Y(num_bits_in(A.size() - 1), 1); for (int i = 0; i < X.size() - 1; i++) { if (evilnum & (1 << i)) Y[i] = 0 - (i + 2); else X[i] = 0 - (i + 2); } if (evilnum & (1 << (X.size() - 1))) Y[i] = 0; else X[i] = 0; answer(C, X, Y); return; } int N = A.size(); vector<int> exits(M + 1, 0); int ptr = 0; for (int i = 0; i < N; i++) { exits[ptr] = A[i]; ptr = A[i]; } answer(exits, {}, {}); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i = 0; i < X.size() - 1; i++) {
      |                   ~~^~~~~~~~~~~~~~
doll.cpp:24:47: error: 'i' was not declared in this scope
   24 |        if (evilnum & (1 << (X.size() - 1))) Y[i] = 0;
      |                                               ^
doll.cpp:25:15: error: 'i' was not declared in this scope
   25 |        else X[i] = 0;
      |               ^