#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define maxn 1010
int n, a[maxn], pf[maxn][30], sf[maxn][30];
int32_t Secret(int32_t X, int32_t Y) {
return (X + 2 * (Y / 2));
}
void dc(int l, int r, int lv) {
int mid = (l+r)/2;
// cout << lv << " " << l << " " << r << " " << mid << endl;
pf[mid+1][lv] = a[mid+1];
for(int i = mid+2; i <= r; i++) {
pf[i][lv] = Secret(pf[i-1][lv],a[i]);
}
sf[mid][lv] = a[mid];
for(int i = mid-1; i >= l; i--) {
sf[i][lv] = Secret(a[i],sf[i+1][lv]);
}
for(int i = mid; i >= l; i--) {
// cout << " " << i << " " << sf[i][lv] << endl;
}
if(l != r) {
dc(l,mid,lv+1);
dc(mid+1,r,lv+1);
}
}
int qrr(int l, int r, int lv, int L, int R) {
int mid = (l+r)/2;
// cout << l << " " << r << " --" << lv << " " << mid << " " << L << " " << R << endl;
if(L >= mid+1) {
return qrr(mid+1,r,lv+1,L,R);
}
else if(R <= mid) {
return qrr(l,mid,lv+1,L,R);
}
else {
return Secret(sf[L][lv],pf[R][lv]);
}
}
int32_t Query(int32_t L, int32_t R) {
if(L == R) return a[L];
return qrr(0,n-1,0,L,R);
}
void Init(int32_t N, int32_t A[]) {
n = N;
for(int i = 0; i < n; i++) a[i] = A[i];
dc(0,n-1,0);
}
// int32_t main() {
// ios::sync_with_stdio(false); cin.tie(0);
// // freopen("in.in", "r", stdin);
// //freopen("out.out", "w", stdout);
// int32_t N;
// cin >> N;
// int32_t A[N];
// for(int i = 0; i < N; i++) cin >> A[i];
// Init(N,A);
// int q; cin >> q;
// while(q--) {
// int l,r; cin >> l >> r;
// cout << Query(l,r) << endl;
// }
// }
Compilation message
/usr/bin/ld: /tmp/ccR1gHw3.o: in function `Secret(int, int)':
secret.cpp:(.text+0x0): multiple definition of `Secret(int, int)'; /tmp/ccw9TQP2.o:grader-full.cpp:(.text+0x2d0): first defined here
collect2: error: ld returned 1 exit status