#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "FFILL"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
const int Max_N = 1e3 + 1;
const int LOG = 9;
int n, a[Max_N];
int st[Max_N][LOG + 1], pos[Max_N];
void dnc(int l, int r, int stage)
{
if(l == r) return;
int mid = l + r >> 1;
st[mid][stage] = a[mid];
st[mid + 1][stage] = a[mid + 1]; pos[mid + 1] |= (1 << stage);
ford(i, mid - 1, l) st[i][stage] = Secret(a[i], st[i + 1][stage]);
forn(i, mid + 2, r) st[i][stage] = Secret(st[i - 1][stage], a[i]), pos[i] |= (1 << stage);
dnc(l, mid, stage + 1);
dnc(mid + 1, r, stage + 1);
}
void Init(int N, int A[])
{
n = N;
FOR(i, n) a[i] = A[i];
dnc(0, n - 1, 0);
}
int Query(int l, int r)
{
if(l == r) return a[l];
int stage = __builtin_ctz(pos[l] ^ pos[r]);
return Secret(st[l][stage], st[r][stage]);
}
Compilation message
secret.cpp: In function 'void dnc(ll, ll, ll)':
secret.cpp:39:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
39 | int mid = l + r >> 1;
| ~~^~~
/usr/bin/ld: /tmp/cc2cImC3.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `Init(int, int*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x30b): undefined reference to `Query(int, int)'
collect2: error: ld returned 1 exit status