#include "secret.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl '\n'
#define pii pair<ll,ll >
#define F first
#define S second
#define double long double
#define all(x) (x).begin(),(x).end()
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll , null_type , less_equal<ll> ,rb_tree_tag ,tree_order_statistics_node_update >ordered_set;
const int MOD=998244353 ;
const int N=1e6+ 7;
const ll INF= 1e18+10;
struct trp{ll F,S,T;};
ll po(ll x,ll y)
{
ll ans = 1;
while(y){
if( y & 1 ) ans *=x;
y /= 2;
x *=x;
x %= MOD;
ans %= MOD;
}
return ans;
}
int n;
ll suf[N][20];
ll pref[N][20];
vector<int>v;
vector<int>pref[N],suf[N];
void build(ll id,ll l,ll r)
{
if(l == r) return;
ll m = (l + r)/2;
pref[id].resize(r-l+3);
suf[id].resize(r-l+3);
suf[id][0] = v[m];
pref[id][0] = v[m+1];
for(ll i=m-1,j=1;i>=l;i--,j++){
suf[id][j] = Secret(suf[id][j-1] , v[i]);
}
for(ll i=m+2,j=1;i<=r;i++,j++){
pref[id][j] = Secret(pref[id][j-1] , v[i]);
}
build(id*2+1,l,m);
build(id*2+2,m+1,r);
}
void Init(int f , int *a)
{
n = f;
for(ll i=0;i<n;i++) v.pb(a[i]);
build(0,0,n-1);
}
ll get_ans(ll id,ll segl,ll segr,ll l,ll r)
{
if(segl == segr) assert(0);
ll m = (segl + segr)/2;
if(m >= l && m < r){
return Secret(suf[id][m-l] , pref[id][r-m-1]);
}
if(l > m) return get_ans(id*2+1,m+1,segr,l,r);
else return get_ans(id*2+2,segl,m,l,r);
}
int Query(int l, int r)
{
if(l == r) return v[l];
return get_ans(0,0,n-1 , l,r);
}
Compilation message
secret.cpp:41:12: error: conflicting declaration 'std::vector<int> pref [1000007]'
41 | vector<int>pref[N],suf[N];
| ^~~~
secret.cpp:39:4: note: previous declaration as 'long long int pref [1000007][20]'
39 | ll pref[N][20];
| ^~~~
secret.cpp:41:20: error: conflicting declaration 'std::vector<int> suf [1000007]'
41 | vector<int>pref[N],suf[N];
| ^~~
secret.cpp:38:4: note: previous declaration as 'long long int suf [1000007][20]'
38 | ll suf[N][20];
| ^~~
secret.cpp: In function 'void build(long long int, long long int, long long int)':
secret.cpp:47:14: error: request for member 'resize' in 'pref[id]', which is of non-class type 'long long int [20]'
47 | pref[id].resize(r-l+3);
| ^~~~~~
secret.cpp:48:13: error: request for member 'resize' in 'suf[id]', which is of non-class type 'long long int [20]'
48 | suf[id].resize(r-l+3);
| ^~~~~~