#include"bits/stdc++.h"
#include "secret.h"
using namespace std;
using ll=long long;
#define S second
#define F first
const int N=1024;
vector<int>tn(N*2,-1);
int mrg(int a,int b){
if(a==-1&&b==-1)return -1;
if(b==-1)return a;
if(a==-1)return b;
return Secret(a,b);
}
void Init(int n,int a[]){
for(int i=0;i<n;i++)tn[i+N]=a[i];
for(int i=N-1;i>0;i--)tn[i]=mrg(tn[i*2],tn[i*2+1]);
}
int Query(int l,int r){
int resL = -1, resR = -1;
for(l+=N, r+=N+1; l<r; l/=2, r/=2){
if(l&1) resL = mrg(resL, tn[l++]);
if(r&1) resR = mrg(tn[--r], resR); // note tn[--r] first, then merge to resR
}
return mrg(resL, resR);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |