#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include "secret.h"
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
// #define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
const ll INF = 1e9;
const int M =(1e3+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
int a[M];
int n;
int dat[18][M], mask[M]; // 18 = ceil(log2(n))
// int pref[M][M];
// int Secret(int x,int y){
// return min(x+2*(y/2),1000000000);
// }
void divi(int l, int r, int lev) { // generate dat and mask
if (l == r) return;
int m = (l+r)/2;
dat[lev][m] = a[m];
for(int i = m-1;i>=l;i--) dat[lev][i] = min(a[i],dat[lev][i+1]);
dat[lev][m+1] = a[m+1];
for(int i =m+2;i<=r;i++) dat[lev][i] = min(dat[lev][i-1],a[i]);
FOR(int i = m+1;i<=r;i++) mask[i] ^= 1<<lev;
divi(l,m,lev+1); divi(m+1,r,lev+1);
}
void Init(int N,int A[]){
n = N;
for(int i = 0;i<n;i++){
a[i+1] = A[i];
}
divi(1,n,0);
}
int Query(int L, int R){
if(L == R){
return a[L+1];
}
L++,R++;
int b = __builtin_ctz(mask[L]^mask[R]);
cout << Secret(dat[b][L],dat[b][R]);
}
// void solve(){
// // }
// signed main(){
// ios_base::sync_with_stdio(0);
// // cin.tie(NULL);
// // freopen(".in","r",stdin);freopen(".out","w",stdout);
// int x;
// cin >> x;
// int v[x];
// for(int i =0;i<x;i++){
// cin >> v[i];
// }
// Init(x,v);
// int q;
// cin >> q;
// while(q--){
// int l,r;
// cin>>l>>r;
// cout<<Query(l,r)<<endl;
// }
// }
Compilation message
secret.cpp:66:29: error: macro "FOR" requires 3 arguments, but only 1 given
66 | FOR(int i = m+1;i<=r;i++) mask[i] ^= 1<<lev;
| ^
secret.cpp:42: note: macro "FOR" defined here
42 | #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
|
secret.cpp: In function 'void divi(int, int, int)':
secret.cpp:66:5: error: 'FOR' was not declared in this scope
66 | FOR(int i = m+1;i<=r;i++) mask[i] ^= 1<<lev;
| ^~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:85:39: warning: control reaches end of non-void function [-Wreturn-type]
85 | cout << Secret(dat[b][L],dat[b][R]);
| ^