Submission #868191

#TimeUsernameProblemLanguageResultExecution timeMemory
868191abczzMechanical Doll (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include "doll.h" #include <iostream> #include <array> #include <vector> #define ll long long using namespace std; ll n, k, cnt; bool X[400000]; vector <ll> C, X, Y; ll solve(ll l, ll r) { ll id = cnt++, chl, chr, mid = (l+r)/2; X.push_back(-1); Y.push_back(-1); if (n < l) { X[id] = -(id+1); Y[id] = -1; return id; } else if (l == r) return 0; X[id] = solve(l, mid); Y[id] = solve(mid+1, r); return id; } void get(ll x) { x *= -1; if (!B[x]) { B[x] ^= 1; if (X[x] != 0) get(X[x]); else { X[x] = k; return; } } else { B[x] ^= 1; if (Y[x] != 0) get(Y[x]); else { Y[x] = k; return; } } } void create_circuit(int M, std::vector<int> A) { n = A.size() + 1; for (int i=0; i<=M; ++i) C.push_back(-1); for (int i=18; i>=0; --i) { if (n <= (1LL << i)) k = (1LL << i); } solve(1, k); for (int i=1; i<n; ++i) { k = i; get(-1); } k = 0; get(-1); answer(C, X, Y); }

Compilation message (stderr)

doll.cpp:11:16: error: conflicting declaration 'std::vector<long long int> X'
   11 | vector <ll> C, X, Y;
      |                ^
doll.cpp:10:6: note: previous declaration as 'bool X [400000]'
   10 | bool X[400000];
      |      ^
doll.cpp: In function 'long long int solve(long long int, long long int)':
doll.cpp:14:5: error: request for member 'push_back' in 'X', which is of non-class type 'bool [400000]'
   14 |   X.push_back(-1);
      |     ^~~~~~~~~
doll.cpp:13:18: warning: unused variable 'chl' [-Wunused-variable]
   13 |   ll id = cnt++, chl, chr, mid = (l+r)/2;
      |                  ^~~
doll.cpp:13:23: warning: unused variable 'chr' [-Wunused-variable]
   13 |   ll id = cnt++, chl, chr, mid = (l+r)/2;
      |                       ^~~
doll.cpp: In function 'void get(long long int)':
doll.cpp:29:8: error: 'B' was not declared in this scope
   29 |   if (!B[x]) {
      |        ^
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:59:10: error: could not convert 'C' from 'vector<long long int>' to 'vector<int>'
   59 |   answer(C, X, Y);
      |          ^
      |          |
      |          vector<long long int>