#include<bits/stdc++.h>
#include "secret.h"
//#include "factories.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const ll N = 1e3 + 5, oo = 1e18 + 7, mod = 1e9 + 7;
int n, a[N];
int arr[N][11];
int val[N][11];
vector<ii> segments[11];
int Secret(int x, int y){
return x + 2 * (y/2);
}
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; i++) a[i + 1] = A[i];
segments[0].pb({1, n});
for(int i = 1; i <= 10; i++){
int temp = 0;
for(auto it : segments[i - 1]){
//cout << i - 1 << " " << it.fi << " " << it.se << "\n";
temp++;
for(int j = it.fi; j <= it.se; j++) arr[j][i - 1] = temp;
if(it.fi == it.se) continue;
int mid = (it.fi + it.se) >> 1;
segments[i].pb({it.fi, mid});
segments[i].pb({mid + 1, it.se});
val[mid][i - 1] = a[mid];
val[mid + 1][i - 1] = a[mid + 1];
for(int j = mid - 1; j >= it.fi; j--){
val[j][i - 1] = Secret(a[j], val[j + 1][i - 1]);
}
for(int j = mid + 2; j <= it.se; j++){
val[j][i - 1] = Secret(a[j], val[j - 1][i - 1]);
}
}
}
}
int Query(int l, int r){
l++, r++;
if(l == r) return a[l];
for(int i = 10; i >= 0; i--){
if(!arr[l][i] || !arr[r][i]) continue;
if(arr[l][i] == arr[r][i]){
//out << l << " " << r << " " << i << "\n";
//cout << val[l][i] << " " << val[r][i] << "\n";
return Secret(val[l][i], val[r][i]);
}
}
}
/*
void process(){
int n, q, a[1005];
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i];
cin >> q;
Init(n, a);
while(q--){
int l, r;
cin >> l >> r;
cout << Query(l, r) << "\n";
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
process();
}*/
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
/usr/bin/ld: /tmp/ccxpbG9U.o: in function `Secret(int, int)':
secret.cpp:(.text+0x50): multiple definition of `Secret(int, int)'; /tmp/cchFtYSY.o:grader-full.cpp:(.text+0x2d0): first defined here
collect2: error: ld returned 1 exit status