#include "secret.h"
#include <vector>
using namespace std;
template<class T> struct offlineDQ {
static const int SZ = (1 << 10)
int n;
T stor[SZ][32-__builtin_clz(SZ)], id = 1;
vector<T> a;
T comb (T a, T b) { return Secret(a, b); } // associative operation
void fill(int l, int r, int ind) {
if (ind < 0) return;
int m = (l+r)/2;
T prod = id;
for(int i = m - 1; i >= l; i--) stor[i][ind] = prod = comb(a[i],prod);
prod = id;
for(int i = m; i < r; i++) stor[i][ind] = prod = comb(prod,a[i]);
fill(l,m,ind-1); fill(m,r,ind-1);
}
void init() {
n = 1; while ((1<<n) < sz(a)) ++n;
a.rsz(1<<n); fill(0,(1<<n),n-1);
}
T query(int l, int r) {
if (l == r) return a[l];
int t = 31-__builtin_clz(r^l);
return comb(stor[l][t],stor[r][t]);
}
};
void Init(int N, int A[]) {
offlineDQ<int> odq;
odq.a.resize(N);
for(int i = 0; i < N; i++) odq.a[i] = A[i];
odq.init();
}
int Query(int L, int R) {
return odq.query(--L, --R);
}
Compilation message
secret.cpp:6:33: error: expected ';' at end of member declaration
6 | static const int SZ = (1 << 10)
| ^
| ;
secret.cpp: In function 'int Query(int, int)':
secret.cpp:39:10: error: 'odq' was not declared in this scope
39 | return odq.query(--L, --R);
| ^~~
secret.cpp: In instantiation of 'void offlineDQ<T>::init() [with T = int]':
secret.cpp:35:12: required from here
secret.cpp:21:28: error: 'sz' was not declared in this scope
21 | n = 1; while ((1<<n) < sz(a)) ++n;
| ~~^~~
secret.cpp:22:5: error: 'class std::vector<int, std::allocator<int> >' has no member named 'rsz'
22 | a.rsz(1<<n); fill(0,(1<<n),n-1);
| ~~^~~