// #include <bits/stdc++.h>
#include "secret.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
using namespace std;
#define endl "\n"
#define pb push_back
// #define int long long
#define fi first
#define se second
const int N = 1e3 + 5, M = 1e9 + 7, LG = 10;
int n , A[N] , sp[N][LG] , B[N];
void Init(int N, int A[]) {
int cr = -1 , l = 0;
n = N;
for (int i=1 ; i<=n ; i++){
B[i] = cr;
if ((1<<l) == i){
l++;
cr++;
B[i]++;
}
}
for (int i=0 ; i<n ; i++){
sp[i][0] = A[i];
}
for (int j=1 ; j<LG ; j++){
for (int i=0 ; i<n ; i++){
if (i+(1<<(j)) >= n) continue;
sp[i][j] = Secret(sp[i][j-1] , sp[i+(1<<(j-1))][j-1]);
}
}
}
int Query(int L, int R) {
int in = L , ans = -1;
while(in <= R){
int dif = (R-in+1);
if (ans==-1){
ans = sp[in][B[dif]];
in += 1<<(B[dif]);
}else{
ans = Secret(ans , sp[in][B[dif]]);
in += 1<<(B[dif]);
}
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |