#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
int node[10][1030];
int n;
int b[1030];
int x;
int mx = 0;
void build(int depth,int l,int r){
int m = (l+r)/2;
if( !(0 <= m && m < x) ) return;
node[depth][m] = b[m];
for(int i = m-1 ; i >= l ; i--){
node[depth][i] = Secret(b[i],node[depth][i+1]);
}
if( m+1 < r && m+1 < x ){
node[depth][m+1] = b[m+1];
for(int i = m+2; i < r ; i++){
if( 0 <= i && i < x ) node[depth][i] = Secret(b[i],node[depth][i-1]);
}
}
//~ cout<<depth<<":\n";
//~ for(int i = l ; i < r ; i++) if( i < x ) cout<<i<<" "<<node[depth][i]<<"\n";
if( r-l > 1 ){
build(depth+1,l,m);
build(depth+1,m,r);
}
}
int q(int l,int r){
if( l == r ) return b[l];
int p = __builtin_clz(l^r) ^ 31;
int pp = mx - 1 - p;
//~ cout<<p<<"\n";
int res = node[pp][l];
if(r & ((1<<p) - 1)){
res = Secret(res,node[p][r]);
}
return res;
}
void Init(int N, std::vector<int> a) {
x = n = N;
int k = 1;
while( k < n ) {
k *= 2;
mx++;
}
n = k;
for(int i = 0 ; i < (int) a.size() ; i++) b[i] = a[i];
build(0,0,n);
}
int Query(int l, int r) {
return q(l,r);
return 0;
}
Compilation message
/usr/bin/ld: /tmp/cczTbwkF.o: in function `main':
grader-full.cpp:(.text.startup+0x2a8): undefined reference to `Init(int, int*)'
collect2: error: ld returned 1 exit status